Allows defining whether Deepgram should send an interruption when the user’s turn has started.

This commit is contained in:
filipi87
2026-01-08 10:36:52 -03:00
parent 8d1286cc00
commit 5e8f0baa12

View File

@@ -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)