From 5e8f0baa129d6950a8fab40b85863d9ad58db741 Mon Sep 17 00:00:00 2001 From: filipi87 Date: Thu, 8 Jan 2026 10:36:52 -0300 Subject: [PATCH] =?UTF-8?q?Allows=20defining=20whether=20Deepgram=20should?= =?UTF-8?q?=20send=20an=20interruption=20when=20the=20user=E2=80=99s=20tur?= =?UTF-8?q?n=20has=20started.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 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 143bfd632..eb6e12b9a 100644 --- a/src/pipecat/services/deepgram/stt.py +++ b/src/pipecat/services/deepgram/stt.py @@ -61,6 +61,7 @@ class DeepgramSTTService(STTService): sample_rate: Optional[int] = None, live_options: Optional[LiveOptions] = None, addons: Optional[Dict] = None, + should_interrupt: bool = True, **kwargs, ): """Initialize the Deepgram STT service. @@ -76,6 +77,7 @@ class DeepgramSTTService(STTService): sample_rate: Audio sample rate. If None, uses default or live_options value. live_options: Deepgram LiveOptions for detailed configuration. addons: Additional Deepgram features to enable. + should_interrupt: Determine whether the bot should be interrupted when Deepgram VAD events are enabled and the system detects that the user is speaking. **kwargs: Additional arguments passed to the parent STTService. """ sample_rate = sample_rate or (live_options.sample_rate if live_options else None) @@ -119,6 +121,7 @@ class DeepgramSTTService(STTService): self.set_model_name(merged_options["model"]) self._settings = merged_options self._addons = addons + self._should_interrupt = should_interrupt self._client = DeepgramClient( api_key, @@ -274,7 +277,8 @@ class DeepgramSTTService(STTService): await self.start_metrics() await self._call_event_handler("on_speech_started", *args, **kwargs) await self.broadcast_frame(UserStartedSpeakingFrame) - await self.push_interruption_task_frame_and_wait() + if self._should_interrupt: + await self.push_interruption_task_frame_and_wait() async def _on_utterance_end(self, *args, **kwargs): await self._call_event_handler("on_utterance_end", *args, **kwargs)