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.
This commit is contained in:
@@ -577,7 +577,11 @@ class DeepgramSTTService(STTService):
|
|||||||
Frame: None (transcription results come via WebSocket callbacks).
|
Frame: None (transcription results come via WebSocket callbacks).
|
||||||
"""
|
"""
|
||||||
if self._connection:
|
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
|
yield None
|
||||||
|
|
||||||
def _build_connect_kwargs(self) -> dict:
|
def _build_connect_kwargs(self) -> dict:
|
||||||
|
|||||||
Reference in New Issue
Block a user