The Azure TTS _handle_completed callback was putting the audio stream completion signal (None) directly into _audio_queue while the last word was still pending in _word_boundary_queue. This caused a race condition where run_tts could exit and TTSStoppedFrame could be emitted before the word processor task had a chance to process and emit the final word's TTSTextFrame. The fix routes the completion signal through _word_boundary_queue as a None sentinel. The word processor task now recognizes this sentinel and only signals _audio_queue after all pending words have been drained. This guarantees the last word's TTSTextFrame is always emitted before TTSStoppedFrame. The cancellation/interruption path (_handle_canceled) is unchanged and still signals _audio_queue directly, which is correct since word ordering does not matter when speech is interrupted.
327 B
327 B
- Fixed Azure TTS last word being missed by observers and RTVI UI. The completion signal was racing with word timestamp processing, causing the final word's
TTSTextFrameto arrive afterTTSStoppedFrame. Completion is now routed through the word boundary queue to ensure all words are processed before signaling stream end.