Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "speechstate",
"license": "GPL-3.0",
"version": "2.13.1",
"version": "2.14.0",
"homepage": "http://localhost/speechstate",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
2 changes: 2 additions & 0 deletions src/speechstate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ const speechstate = setup({
input: {
azureAuthorizationToken: context.azureAuthorizationToken,
ttsDefaultVoice: context.settings.ttsDefaultVoice,
ttsDefaultFillerDelay: context.settings.ttsDefaultFillerDelay,
ttsDefaultFiller: context.settings.ttsDefaultFiller,
ttsLexicon: context.settings.ttsLexicon,
audioContext: context.audioContext,
azureRegion: context.settings.azureRegion,
Expand Down
12 changes: 9 additions & 3 deletions src/tts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export const ttsMachine = setup({
return {
buffer:
context.buffer.substring(0, spaceIndex) +
" um," +
" " +
context.ttsDefaultFiller +
context.buffer.substring(spaceIndex),
};
}),
Expand Down Expand Up @@ -300,6 +301,8 @@ export const ttsMachine = setup({
context: ({ input }) => ({
azureAuthorizationToken: input.azureAuthorizationToken,
ttsDefaultVoice: input.ttsDefaultVoice || "en-US-DavisNeural",
ttsDefaultFillerDelay: input.ttsDefaultFillerDelay || 500,
ttsDefaultFiller: input.ttsDefaultFiller || "um,",
ttsLexicon: input.ttsLexicon,
audioContext: input.audioContext,
azureRegion: input.azureRegion,
Expand Down Expand Up @@ -333,10 +336,13 @@ export const ttsMachine = setup({
target: "BufferedSpeaker",
guard: ({ event }) => !!event.value.stream,
actions: assign({
agenda: ({ event }) =>
agenda: ({ context, event }) =>
event.value.fillerDelay
? event.value
: { ...event.value, fillerDelay: 500 },
: {
...event.value,
fillerDelay: context.ttsDefaultFillerDelay,
},
}),
},
{
Expand Down
4 changes: 4 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export interface Settings {
speechRecognitionEndpointId?: string;
ttsDefaultVoice?: string;
ttsLexicon?: string;
ttsDefaultFillerDelay?: number;
ttsDefaultFiller?: string;
newTokenInterval?: number;
}

Expand Down Expand Up @@ -140,6 +142,8 @@ export interface TTSInit {
audioContext: AudioContext;
azureRegion: string;
ttsDefaultVoice: string;
ttsDefaultFillerDelay?: number;
ttsDefaultFiller?: string;
ttsLexicon?: string;
locale: string;
}
Expand Down
2 changes: 1 addition & 1 deletion test/server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async function run() {
} else {
clearInterval(interval);
}
}, 300);
}, 500);

res.on("close", () => {
clearInterval(interval);
Expand Down
16 changes: 14 additions & 2 deletions test/tts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ describe("Synthesis test", async () => {
return {
ssRef: spawn(speechstate, {
input: {
ttsDefaultFiller: "um the filler,",
ttsDefaultFillerDelay: 100,
noPonyfill: false,
azureRegion: "swedencentral",
azureCredentials: {
Expand Down Expand Up @@ -89,7 +91,7 @@ describe("Synthesis test", async () => {
expect(snapshot).toBeTruthy();
});

test("synthesise from stream", async () => {
test.only("synthesise from stream", async () => {
actor.getSnapshot().context.ssRef.send({
type: "SPEAK",
value: { utterance: "", stream: "http://localhost:3000/sse/1" },
Expand All @@ -98,6 +100,16 @@ describe("Synthesis test", async () => {
expect(snapshot).toBeTruthy();
});

test.only("synthesise from stream; different filler and timeout", async () => {
actor.getSnapshot().context.ssRef.send({
type: "SPEAK",
value: { utterance: "", stream: "http://localhost:3000/sse/1", fillerDelay: 100_000 },
});
const snapshot = await waitForView(actor, "speaking", 1000);
expect(snapshot).toBeTruthy();
});


test("synthesise from stream; stop and restart on CONTROL", async () => {
actor.getSnapshot().context.ssRef.send({
type: "SPEAK",
Expand Down Expand Up @@ -152,7 +164,7 @@ describe("Synthesis test", async () => {
expect(snapshot).toBeTruthy();
});

test.only("synthesise from stream, use cache", async () => {
test("synthesise from stream, use cache", async () => {
actor.getSnapshot().context.ssRef.send({
type: "SPEAK",
value: {
Expand Down