Merge pull request #1975 from pipecat-ai/mb/11labs-flush-context-reset

fix: ElevenLabsTTSService reset context when flushing audio
This commit is contained in:
Mark Backman
2025-06-09 13:21:25 -04:00
committed by GitHub
2 changed files with 9 additions and 3 deletions

View File

@@ -26,6 +26,9 @@ asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
- Fixed an issue with various TTS services that would cause audio glitches at
the start of every bot turn.
- Fixed an `ElevenLabsTTSService` issue where a context warning was printed
when pushing a `TTSSpeakFrame`.
- Fixed an `AssemblyAISTTService` issue that could cause unexpected behavior
when yielding empty `Frame()`s.

View File

@@ -279,9 +279,12 @@ class ElevenLabsTTSService(AudioContextWordTTSService):
await self._disconnect()
async def flush_audio(self):
if self._websocket and self._context_id:
msg = {"context_id": self._context_id, "flush": True}
await self._websocket.send(json.dumps(msg))
if not self._context_id or not self._websocket:
return
logger.trace(f"{self}: flushing audio")
msg = {"context_id": self._context_id, "flush": True}
await self._websocket.send(json.dumps(msg))
self._context_id = None
async def push_frame(self, frame: Frame, direction: FrameDirection = FrameDirection.DOWNSTREAM):
await super().push_frame(frame, direction)