From 846ae765e5dccf175738e76b298a0a6e1fe2dcb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Fri, 19 Jul 2024 11:48:59 -0700 Subject: [PATCH] services(TTSService): fix sentence cleanup --- CHANGELOG.md | 3 +++ src/pipecat/services/ai_services.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 286325679..c28f5ede1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `TTSService` end of sentence detection has been improved. It now works with acronyms, numbers, hours and others. +- Fixed an issue in `TTSService` that would not properly flush the current + aggregated sentence if an `LLMFullResponseEndFrame` was found. + ### Performance - `CartesiaTTSService` now uses websockets which improves speed. It also diff --git a/src/pipecat/services/ai_services.py b/src/pipecat/services/ai_services.py index e32419965..ec89b9eba 100644 --- a/src/pipecat/services/ai_services.py +++ b/src/pipecat/services/ai_services.py @@ -201,8 +201,9 @@ class TTSService(AIService): elif isinstance(frame, StartInterruptionFrame): await self._handle_interruption(frame, direction) elif isinstance(frame, LLMFullResponseEndFrame) or isinstance(frame, EndFrame): + sentence = self._current_sentence self._current_sentence = "" - await self._push_tts_frames(self._current_sentence) + await self._push_tts_frames(sentence) if isinstance(frame, LLMFullResponseEndFrame): if self._push_text_frames: await self.push_frame(frame, direction)