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=}")