From 9001cb17ce12b60a3bed6dba669cd4f0a38529eb Mon Sep 17 00:00:00 2001 From: balalo Date: Fri, 6 Dec 2024 17:42:46 +0100 Subject: [PATCH] Fix interruption frame to avoid issues with sending None --- src/pipecat/services/cartesia.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pipecat/services/cartesia.py b/src/pipecat/services/cartesia.py index f92a78aa4..fd75615ab 100644 --- a/src/pipecat/services/cartesia.py +++ b/src/pipecat/services/cartesia.py @@ -210,9 +210,10 @@ class CartesiaTTSService(WordTTSService): async def _handle_interruption(self, frame: StartInterruptionFrame, direction: FrameDirection): await super()._handle_interruption(frame, direction) await self.stop_all_metrics() - cancel_msg = json.dumps({"context_id": self._context_id, "cancel": True}) - await self._get_websocket().send(cancel_msg) - self._context_id = None + if not self._context_id: + cancel_msg = json.dumps({"context_id": self._context_id, "cancel": True}) + await self._get_websocket().send(cancel_msg) + self._context_id = None async def flush_audio(self): if not self._context_id or not self._websocket: