From 3069deb92f7c1bcbd22a6d227855bc9399f6652b Mon Sep 17 00:00:00 2001 From: filipi87 Date: Thu, 8 Jan 2026 10:50:33 -0300 Subject: [PATCH] =?UTF-8?q?Allows=20defining=20whether=20Speechmatics=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/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.