From e6f269a903626e60bd5126efa4a71834a2ee7291 Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Fri, 7 Mar 2025 15:50:48 -0500 Subject: [PATCH] Add flush_audio to FishTTSService --- CHANGELOG.md | 2 ++ src/pipecat/services/fish.py | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c4ee5eaf..b1de5e50a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added support for Chirp voices in `GoogleTTSService`. +- Added a `flush_audio()` method to `FishTTSService`. + - Added `on_user_turn_audio_data` and `on_bot_turn_audio_data` to `AudioBufferProcessor`. This gives the ability to grab the audio of only that turn for both the user and the bot. diff --git a/src/pipecat/services/fish.py b/src/pipecat/services/fish.py index 0b2729958..96968d6e9 100644 --- a/src/pipecat/services/fish.py +++ b/src/pipecat/services/fish.py @@ -148,6 +148,14 @@ class FishAudioTTSService(InterruptibleTTSService): except Exception as e: logger.error(f"Error closing websocket: {e}") + async def flush_audio(self): + """Flush any buffered audio by sending a flush event to Fish Audio.""" + logger.trace(f"{self}: Flushing audio buffers") + if not self._websocket: + return + flush_message = {"event": "flush"} + await self._get_websocket().send(ormsgpack.packb(flush_message)) + def _get_websocket(self): if self._websocket: return self._websocket