From 22557fa66866e67f351ed67c5d4975469b90dfed Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Wed, 15 Oct 2025 09:05:40 -0400 Subject: [PATCH] Fix an issue in ElevenLabsHttpTTSService where the last word is not emitted --- CHANGELOG.md | 4 ++++ src/pipecat/services/elevenlabs/tts.py | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index acd680d5a..1832b9a0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Fixed an issue in `ElevenLabsTTSService` and `ElevenLabsHttpTTSService` where + the Flash models would split words, resulting in a space being inserted + between words. + - Fixed an issue where audio filters' `stop()` would not be called when using `CancelFrame`. diff --git a/src/pipecat/services/elevenlabs/tts.py b/src/pipecat/services/elevenlabs/tts.py index 641f50aa1..460b23d18 100644 --- a/src/pipecat/services/elevenlabs/tts.py +++ b/src/pipecat/services/elevenlabs/tts.py @@ -1070,6 +1070,14 @@ class ElevenLabsHttpTTSService(WordTTSService): logger.error(f"Error processing response: {e}", exc_info=True) continue + # After processing all chunks, emit any remaining partial word + # since this is the end of the utterance + if self._partial_word: + final_word_time = [(self._partial_word, self._partial_word_start_time)] + await self.add_word_timestamps(final_word_time) + self._partial_word = "" + self._partial_word_start_time = 0.0 + # After processing all chunks, add the total utterance duration # to the cumulative time to ensure next utterance starts after this one if utterance_duration > 0: