From 2836b1ea7e7e6bc70e61c63551c8a3f526871f02 Mon Sep 17 00:00:00 2001 From: filipi87 Date: Thu, 19 Mar 2026 10:07:25 -0300 Subject: [PATCH] Fixing the frame ordering of the AggregatedTextFrame. --- src/pipecat/services/tts_service.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pipecat/services/tts_service.py b/src/pipecat/services/tts_service.py index 303072373..dd27314f5 100644 --- a/src/pipecat/services/tts_service.py +++ b/src/pipecat/services/tts_service.py @@ -1006,7 +1006,12 @@ class TTSService(AIService): # Route AggregatedTextFrame through the serialization queue so it is emitted # immediately before the TTSStartedFrame of the audio context it describes, # rather than racing ahead of audio frames from a previous context. - await self._serialization_queue.put(src_frame) + if not self.audio_context_available(context_id): + await self._serialization_queue.put(src_frame) + # Otherwise, if the context already exists, we append the AggregatedTextFrame + # to the existing context queue. + else: + await self.append_to_audio_context(context_id, src_frame) # Note: Text transformations are meant to only affect the text sent to the TTS for # TTS-specific purposes. This allows for explicit TTS modifications (e.g., inserting