From cfe91d11ecb7bf1b07c674ae9c0e3de041eaa653 Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Thu, 26 Mar 2026 08:45:32 -0400 Subject: [PATCH] Handle Deepgram SDK 6.x send_media() exceptions Deepgram SDK 6.x surfaces connection errors from send_media() instead of silently swallowing them. This causes error floods when the WebSocket disconnects since every queued audio frame hits the dead connection. Wrap send_media() in try/except: on failure, log one warning and set self._connection = None so subsequent frames skip until the existing _connection_handler reconnects. --- src/pipecat/services/deepgram/stt.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pipecat/services/deepgram/stt.py b/src/pipecat/services/deepgram/stt.py index 0fb891d61..63e7a05ba 100644 --- a/src/pipecat/services/deepgram/stt.py +++ b/src/pipecat/services/deepgram/stt.py @@ -577,7 +577,11 @@ class DeepgramSTTService(STTService): Frame: None (transcription results come via WebSocket callbacks). """ if self._connection: - await self._connection.send_media(audio) + try: + await self._connection.send_media(audio) + except Exception as e: + logger.warning(f"{self}: send_media failed, connection will reconnect: {e}") + self._connection = None yield None def _build_connect_kwargs(self) -> dict: