fix(tts): add speak() for complete responses; fix briefing message commit race

This commit is contained in:
2026-04-03 14:18:34 -04:00
parent 8024706870
commit c81a499e6e
4 changed files with 26 additions and 8 deletions
+16 -1
View File
@@ -52,6 +52,8 @@ export interface UseStreamingTtsReturn {
speaking: ComputedRef<boolean>
/** Cancel all in-flight synthesis/playback and clear the queue. */
stop: () => void
/** Speak a complete text through the same sentence-chunking pipeline. */
speak: (text: string) => void
}
export function useStreamingTts(options: UseStreamingTtsOptions): UseStreamingTtsReturn {
@@ -139,5 +141,18 @@ export function useStreamingTts(options: UseStreamingTtsOptions): UseStreamingTt
}
})
return { speaking, stop }
function speak(text: string): void {
stop()
if (!text.trim()) return
const myAbortId = abortId
const { sentences, remainder } = extractSentences(text)
for (const sentence of sentences) {
enqueueSentence(sentence, myAbortId)
}
if (remainder.trim().length >= MIN_CHARS) {
enqueueSentence(remainder.trim(), myAbortId)
}
}
return { speaking, stop, speak }
}