From 16725700601dfa42b15c67c2d6eab09f8545854c Mon Sep 17 00:00:00 2001 From: James Hush Date: Wed, 17 Sep 2025 15:01:49 +0800 Subject: [PATCH] Final fix for AsyncAI TTS transcription duplication The debug logging confirmed the issue was resolved with the proper flag tracking and reset_word_timestamps() call. AsyncAI TTS now generates transcription frames once per text input, matching Cartesia TTS behavior. Working solution: - Track transcription generation with _transcription_generated flag - Reset flag and word timestamps for each new text input - Only generate transcription on first audio chunk per text - Proper cleanup ensures no duplicate transcriptions --- src/pipecat/services/asyncai/tts.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/pipecat/services/asyncai/tts.py b/src/pipecat/services/asyncai/tts.py index feb042c9e..391ad50a0 100644 --- a/src/pipecat/services/asyncai/tts.py +++ b/src/pipecat/services/asyncai/tts.py @@ -302,10 +302,6 @@ class AsyncAITTSService(WebsocketWordTTSService): await self.add_word_timestamps([("TTSStoppedFrame", 0), ("Reset", 0)]) self._transcription_generated = True logger.debug(f"{self}: Transcription flag set to True") - else: - logger.debug( - f"{self}: Skipping transcription generation - already generated: {self._transcription_generated}, text: '{self._current_text}'" - ) frame = TTSAudioRawFrame( audio=base64.b64decode(msg["audio"]), @@ -346,7 +342,7 @@ class AsyncAITTSService(WebsocketWordTTSService): Yields: Frame: Audio frames containing the synthesized speech. """ - logger.debug(f"{self}: Generating TTS [{text}]") + logger.debug(f"{self}: AsyncAI Generating TTS [{text}]") try: if not self._websocket or self._websocket.state is State.CLOSED: