Merge pull request #4127 from pipecat-ai/mb/tts-text-frame-ordering

Fix LLMFullResponseEndFrame racing ahead of final TTSTextFrame
This commit is contained in:
Mark Backman
2026-03-24 15:39:06 -04:00
committed by GitHub
3 changed files with 101 additions and 1 deletions

View File

@@ -750,7 +750,11 @@ class TTSService(AIService):
self._processing_text = False
if isinstance(frame, LLMFullResponseEndFrame):
if self._push_text_frames:
await self.push_frame(frame, direction)
# Route through the serialization queue so the frame is
# emitted only after the audio context has been fully
# drained (including the final TTSTextFrame). Pushing
# directly would let it race ahead of queued text frames.
await self._serialization_queue.put(frame)
else:
await self.push_frame(frame, direction)