Allows defining whether Flux should send an interruption when the user’s turn has started.
This commit is contained in:
@@ -116,6 +116,7 @@ class DeepgramFluxSTTService(WebsocketSTTService):
|
|||||||
model: str = "flux-general-en",
|
model: str = "flux-general-en",
|
||||||
flux_encoding: str = "linear16",
|
flux_encoding: str = "linear16",
|
||||||
params: Optional[InputParams] = None,
|
params: Optional[InputParams] = None,
|
||||||
|
should_interrupt: bool = True,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
):
|
):
|
||||||
"""Initialize the Deepgram Flux STT service.
|
"""Initialize the Deepgram Flux STT service.
|
||||||
@@ -129,6 +130,7 @@ class DeepgramFluxSTTService(WebsocketSTTService):
|
|||||||
Raw signed little-endian 16-bit PCM encoding.
|
Raw signed little-endian 16-bit PCM encoding.
|
||||||
params: InputParams instance containing detailed API configuration options.
|
params: InputParams instance containing detailed API configuration options.
|
||||||
If None, default parameters will be used.
|
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.
|
**kwargs: Additional arguments passed to the parent WebsocketSTTService class.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
@@ -166,6 +168,7 @@ class DeepgramFluxSTTService(WebsocketSTTService):
|
|||||||
self._url = url
|
self._url = url
|
||||||
self._model = model
|
self._model = model
|
||||||
self._params = params or DeepgramFluxSTTService.InputParams()
|
self._params = params or DeepgramFluxSTTService.InputParams()
|
||||||
|
self._should_interrupt = should_interrupt
|
||||||
self._flux_encoding = flux_encoding
|
self._flux_encoding = flux_encoding
|
||||||
# This is the currently only supported language
|
# This is the currently only supported language
|
||||||
self._language = Language.EN
|
self._language = Language.EN
|
||||||
@@ -592,7 +595,8 @@ class DeepgramFluxSTTService(WebsocketSTTService):
|
|||||||
logger.debug("User started speaking")
|
logger.debug("User started speaking")
|
||||||
self._user_is_speaking = True
|
self._user_is_speaking = True
|
||||||
await self.broadcast_frame(UserStartedSpeakingFrame)
|
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.start_metrics()
|
||||||
await self._call_event_handler("on_start_of_turn", transcript)
|
await self._call_event_handler("on_start_of_turn", transcript)
|
||||||
if transcript:
|
if transcript:
|
||||||
|
|||||||
Reference in New Issue
Block a user