From 0a913045a8927c686863d445a18813fbac28b72c Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Fri, 3 Apr 2026 14:21:44 -0400 Subject: [PATCH] fix(tts): play() must return a promise that resolves when audio finishes Without this, await audio.play() resolves immediately after source.start(), so the playQueue chains the next sentence before the current one finishes, causing overlapping / interrupted playback. --- frontend/src/composables/useVoiceAudio.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/frontend/src/composables/useVoiceAudio.ts b/frontend/src/composables/useVoiceAudio.ts index be490f7..1e9945f 100644 --- a/frontend/src/composables/useVoiceAudio.ts +++ b/frontend/src/composables/useVoiceAudio.ts @@ -39,11 +39,14 @@ export function useVoiceAudio() { currentSource = source playing.value = true - source.onended = () => { - playing.value = false - currentSource = null - } - source.start(0) + return new Promise((resolve) => { + source.onended = () => { + playing.value = false + currentSource = null + resolve() + } + source.start(0) + }) } function stop(): void {