From 5e8f0baa129d6950a8fab40b85863d9ad58db741 Mon Sep 17 00:00:00 2001 From: filipi87 Date: Thu, 8 Jan 2026 10:36:52 -0300 Subject: [PATCH 1/5] =?UTF-8?q?Allows=20defining=20whether=20Deepgram=20sh?= =?UTF-8?q?ould=20send=20an=20interruption=20when=20the=20user=E2=80=99s?= =?UTF-8?q?=20turn=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) From 68c9c017478840b2d12a811143f34882b862143e Mon Sep 17 00:00:00 2001 From: filipi87 Date: Thu, 8 Jan 2026 10:44:53 -0300 Subject: [PATCH 2/5] =?UTF-8?q?Allows=20defining=20whether=20Flux=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/flux/stt.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pipecat/services/deepgram/flux/stt.py b/src/pipecat/services/deepgram/flux/stt.py index 17f970587..cc2df29e2 100644 --- a/src/pipecat/services/deepgram/flux/stt.py +++ b/src/pipecat/services/deepgram/flux/stt.py @@ -116,6 +116,7 @@ class DeepgramFluxSTTService(WebsocketSTTService): model: str = "flux-general-en", flux_encoding: str = "linear16", params: Optional[InputParams] = None, + should_interrupt: bool = True, **kwargs, ): """Initialize the Deepgram Flux STT service. @@ -129,6 +130,7 @@ class DeepgramFluxSTTService(WebsocketSTTService): Raw signed little-endian 16-bit PCM encoding. params: InputParams instance containing detailed API configuration options. If None, default parameters will be used. + should_interrupt: Determine whether the bot should be interrupted when Flux detects that the user is speaking. **kwargs: Additional arguments passed to the parent WebsocketSTTService class. Examples: @@ -166,6 +168,7 @@ class DeepgramFluxSTTService(WebsocketSTTService): self._url = url self._model = model self._params = params or DeepgramFluxSTTService.InputParams() + self._should_interrupt = should_interrupt self._flux_encoding = flux_encoding # This is the currently only supported language self._language = Language.EN @@ -592,7 +595,8 @@ class DeepgramFluxSTTService(WebsocketSTTService): logger.debug("User started speaking") self._user_is_speaking = True 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() await self.start_metrics() await self._call_event_handler("on_start_of_turn", transcript) if transcript: From 3069deb92f7c1bcbd22a6d227855bc9399f6652b Mon Sep 17 00:00:00 2001 From: filipi87 Date: Thu, 8 Jan 2026 10:50:33 -0300 Subject: [PATCH 3/5] =?UTF-8?q?Allows=20defining=20whether=20Speechmatics?= =?UTF-8?q?=20should=20send=20an=20interruption=20when=20the=20user?= =?UTF-8?q?=E2=80=99s=20turn=20has=20started.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pipecat/services/speechmatics/stt.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pipecat/services/speechmatics/stt.py b/src/pipecat/services/speechmatics/stt.py index ec5c6fecd..4f638d6a8 100644 --- a/src/pipecat/services/speechmatics/stt.py +++ b/src/pipecat/services/speechmatics/stt.py @@ -287,6 +287,7 @@ class SpeechmaticsSTTService(STTService): base_url: str | None = None, sample_rate: int | None = None, params: InputParams | None = None, + should_interrupt: bool = True, **kwargs, ): """Initialize the Speechmatics STT service. @@ -298,6 +299,7 @@ class SpeechmaticsSTTService(STTService): or defaults to `wss://eu2.rt.speechmatics.com/v2`. sample_rate: Optional audio sample rate in Hz. params: Optional[InputParams]: Input parameters for the service. + should_interrupt: Determine whether the bot should be interrupted when Speechmatics detects that the user is speaking. **kwargs: Additional arguments passed to STTService. """ super().__init__(sample_rate=sample_rate, **kwargs) @@ -316,6 +318,7 @@ class SpeechmaticsSTTService(STTService): # Default params params = params or SpeechmaticsSTTService.InputParams() + self._should_interrupt = should_interrupt # Deprecation check self._check_deprecated_args(kwargs, params) @@ -623,7 +626,8 @@ class SpeechmaticsSTTService(STTService): logger.debug(f"{self} StartOfTurn received") # await self.start_processing_metrics() 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 _handle_end_of_turn(self, message: dict[str, Any]) -> None: """Handle EndOfTurn events. From c8fa9d34e10afd03ea6fd74db8bacc5c025b5ec3 Mon Sep 17 00:00:00 2001 From: filipi87 Date: Thu, 8 Jan 2026 10:58:07 -0300 Subject: [PATCH 4/5] Adding a changelog entry for the new should_interrupt property. --- changelog/3374.added.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/3374.added.md diff --git a/changelog/3374.added.md b/changelog/3374.added.md new file mode 100644 index 000000000..eb04650ef --- /dev/null +++ b/changelog/3374.added.md @@ -0,0 +1 @@ +- Added `should_interrupt` property to `DeepgramFluxSTTService`, `DeepgramSTTService`, and `SpeechmaticsSTTService` to configure whether the bot should be interrupted when the external service detects user speech. \ No newline at end of file From b8af3fa2141688e5a2bfe3310f900c0cfd6ca152 Mon Sep 17 00:00:00 2001 From: filipi87 Date: Thu, 8 Jan 2026 14:53:29 -0300 Subject: [PATCH 5/5] Improving should_interrupt docs for Speechmatics. --- src/pipecat/services/speechmatics/stt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pipecat/services/speechmatics/stt.py b/src/pipecat/services/speechmatics/stt.py index 4f638d6a8..5d6a5e205 100644 --- a/src/pipecat/services/speechmatics/stt.py +++ b/src/pipecat/services/speechmatics/stt.py @@ -299,7 +299,7 @@ class SpeechmaticsSTTService(STTService): or defaults to `wss://eu2.rt.speechmatics.com/v2`. sample_rate: Optional audio sample rate in Hz. params: Optional[InputParams]: Input parameters for the service. - should_interrupt: Determine whether the bot should be interrupted when Speechmatics detects that the user is speaking. + should_interrupt: Determine whether the bot should be interrupted when Speechmatics turn_detection_mode is configured to detect user speech. **kwargs: Additional arguments passed to STTService. """ super().__init__(sample_rate=sample_rate, **kwargs)