From d125a3873720c41141f948e35b7190ddd8fda7bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Sun, 10 Nov 2024 09:55:45 +0100 Subject: [PATCH] services(cartesia): generated TTSStoppedFrame after no more audio The TTSStoppedFrame should be generated when the TTS services stoped generating audio not when the bot stops speaking. --- src/pipecat/services/cartesia.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pipecat/services/cartesia.py b/src/pipecat/services/cartesia.py index ff7b200c1..7f30df448 100644 --- a/src/pipecat/services/cartesia.py +++ b/src/pipecat/services/cartesia.py @@ -228,14 +228,13 @@ class CartesiaTTSService(WordTTSService): if not msg or msg["context_id"] != self._context_id: continue if msg["type"] == "done": + await self.push_frame(TTSStoppedFrame()) await self.stop_ttfb_metrics() # Unset _context_id but not the _context_id_start_timestamp # because we are likely still playing out audio and need the # timestamp to set send context frames. self._context_id = None - await self.add_word_timestamps( - [("TTSStoppedFrame", 0), ("LLMFullResponseEndFrame", 0), ("Reset", 0)] - ) + await self.add_word_timestamps([("LLMFullResponseEndFrame", 0), ("Reset", 0)]) elif msg["type"] == "timestamps": await self.add_word_timestamps( list(zip(msg["word_timestamps"]["words"], msg["word_timestamps"]["start"]))