From 6422661d08be83ce18e7688d1b3da2b810f3103f Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Fri, 27 Mar 2026 14:40:48 -0400 Subject: [PATCH] Fix Deepgram STT compatibility with deepgram-sdk 6.1.0 The SDK now requires explicit message objects for send_keep_alive, send_close_stream, and send_finalize instead of no-arg calls. --- src/pipecat/services/deepgram/stt.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pipecat/services/deepgram/stt.py b/src/pipecat/services/deepgram/stt.py index 63e7a05ba..d58958da2 100644 --- a/src/pipecat/services/deepgram/stt.py +++ b/src/pipecat/services/deepgram/stt.py @@ -41,6 +41,9 @@ try: from deepgram import AsyncDeepgramClient from deepgram.core.events import EventType from deepgram.listen.v1.types import ( + ListenV1CloseStream, + ListenV1Finalize, + ListenV1KeepAlive, ListenV1Results, ListenV1SpeechStarted, ListenV1UtteranceEnd, @@ -658,7 +661,7 @@ class DeepgramSTTService(STTService): self._connection = None if connection: - await connection.send_close_stream() + await connection.send_close_stream(ListenV1CloseStream(type="CloseStream")) await self.cancel_task(self._connection_task) self._connection_task = None @@ -703,7 +706,7 @@ class DeepgramSTTService(STTService): await asyncio.sleep(5) if self._connection: try: - await self._connection.send_keep_alive() + await self._connection.send_keep_alive(ListenV1KeepAlive(type="KeepAlive")) logger.trace(f"{self}: Sent keepalive") except Exception as e: logger.warning(f"{self}: Keepalive failed: {e}") @@ -800,5 +803,5 @@ class DeepgramSTTService(STTService): # Mark that we're awaiting a from_finalize response if self._connection: self.request_finalize() - await self._connection.send_finalize() + await self._connection.send_finalize(ListenV1Finalize(type="Finalize")) logger.trace(f"Triggered finalize event on: {frame.name=}, {direction=}")