diff --git a/src/pipecat/services/assemblyai/stt.py b/src/pipecat/services/assemblyai/stt.py index 6b2607587..f87a5a0e5 100644 --- a/src/pipecat/services/assemblyai/stt.py +++ b/src/pipecat/services/assemblyai/stt.py @@ -433,7 +433,11 @@ class AssemblyAISTTService(WebsocketSTTService): while len(self._audio_buffer) >= self._chunk_size_bytes: chunk = bytes(self._audio_buffer[: self._chunk_size_bytes]) self._audio_buffer = self._audio_buffer[self._chunk_size_bytes :] - await self._websocket.send(chunk) + try: + await self._websocket.send(chunk) + except Exception as e: + logger.warning(f"{self}: send failed: {e}") + break yield None diff --git a/src/pipecat/services/cartesia/stt.py b/src/pipecat/services/cartesia/stt.py index 191f778b3..018d95e6a 100644 --- a/src/pipecat/services/cartesia/stt.py +++ b/src/pipecat/services/cartesia/stt.py @@ -290,7 +290,10 @@ class CartesiaSTTService(WebsocketSTTService): if not self._websocket or self._websocket.state is not State.OPEN: await self._connect() - await self._websocket.send(audio) + try: + await self._websocket.send(audio) + except Exception as e: + logger.warning(f"{self}: send failed: {e}") yield None async def _connect(self): diff --git a/src/pipecat/services/gradium/stt.py b/src/pipecat/services/gradium/stt.py index 70fde8145..412f0a1b3 100644 --- a/src/pipecat/services/gradium/stt.py +++ b/src/pipecat/services/gradium/stt.py @@ -350,7 +350,11 @@ class GradiumSTTService(WebsocketSTTService): chunk = base64.b64encode(chunk).decode("utf-8") msg = {"type": "audio", "audio": chunk} if self._websocket and self._websocket.state is State.OPEN: - await self._websocket.send(json.dumps(msg)) + try: + await self._websocket.send(json.dumps(msg)) + except Exception as e: + logger.warning(f"{self}: send failed: {e}") + break yield None diff --git a/src/pipecat/services/soniox/stt.py b/src/pipecat/services/soniox/stt.py index 30c813c9d..95418011c 100644 --- a/src/pipecat/services/soniox/stt.py +++ b/src/pipecat/services/soniox/stt.py @@ -412,7 +412,10 @@ class SonioxSTTService(WebsocketSTTService): Frame: None (transcription results come via WebSocket callbacks). """ if self._websocket and self._websocket.state is State.OPEN: - await self._websocket.send(audio) + try: + await self._websocket.send(audio) + except Exception as e: + logger.warning(f"{self}: send failed: {e}") yield None