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.
This commit is contained in:
@@ -39,11 +39,14 @@ export function useVoiceAudio() {
|
|||||||
currentSource = source
|
currentSource = source
|
||||||
playing.value = true
|
playing.value = true
|
||||||
|
|
||||||
source.onended = () => {
|
return new Promise<void>((resolve) => {
|
||||||
playing.value = false
|
source.onended = () => {
|
||||||
currentSource = null
|
playing.value = false
|
||||||
}
|
currentSource = null
|
||||||
source.start(0)
|
resolve()
|
||||||
|
}
|
||||||
|
source.start(0)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function stop(): void {
|
function stop(): void {
|
||||||
|
|||||||
Reference in New Issue
Block a user