Updated to have default as FIXED for Pipecat VAD.

This commit is contained in:
Sam Sykes
2025-12-31 19:05:29 +00:00
parent 8e7a951af8
commit 8203ad08a8

View File

@@ -46,6 +46,7 @@ try:
SpeakerFocusConfig, SpeakerFocusConfig,
SpeakerFocusMode, SpeakerFocusMode,
SpeakerIdentifier, SpeakerIdentifier,
SpeechSegmentConfig,
VoiceAgentClient, VoiceAgentClient,
VoiceAgentConfig, VoiceAgentConfig,
VoiceAgentConfigPreset, VoiceAgentConfigPreset,
@@ -65,13 +66,14 @@ class TurnDetectionMode(str, Enum):
"""Endpoint and turn detection handling mode. """Endpoint and turn detection handling mode.
How the STT engine handles the endpointing of speech. If using Pipecat's built-in endpointing, How the STT engine handles the endpointing of speech. If using Pipecat's built-in endpointing,
then use `TurnDetectionMode.EXTERNAL` (default). then use `TurnDetectionMode.FIXED` (default).
To use the STT engine's built-in endpointing, then use `TurnDetectionMode.ADAPTIVE` for simple To use the STT engine's built-in endpointing, then use `TurnDetectionMode.ADAPTIVE` for simple
voice activity detection or `TurnDetectionMode.SMART_TURN` for more advanced ML-based voice activity detection or `TurnDetectionMode.SMART_TURN` for more advanced ML-based
endpointing. endpointing.
""" """
FIXED = "fixed"
EXTERNAL = "external" EXTERNAL = "external"
ADAPTIVE = "adaptive" ADAPTIVE = "adaptive"
SMART_TURN = "smart_turn" SMART_TURN = "smart_turn"
@@ -102,9 +104,9 @@ class SpeechmaticsSTTService(STTService):
language: Language code for transcription. Defaults to `Language.EN`. language: Language code for transcription. Defaults to `Language.EN`.
turn_detection_mode: Endpoint handling, one of `TurnDetectionMode.EXTERNAL`, turn_detection_mode: Endpoint handling, one of `TurnDetectionMode.FIXED`,
`TurnDetectionMode.ADAPTIVE` and `TurnDetectionMode.SMART_TURN`. `TurnDetectionMode.EXTERNAL`, `TurnDetectionMode.ADAPTIVE` and
Defaults to `TurnDetectionMode.EXTERNAL`. `TurnDetectionMode.SMART_TURN`. Defaults to `TurnDetectionMode.FIXED`.
speaker_active_format: Formatter for active speaker ID. This formatter is used to format speaker_active_format: Formatter for active speaker ID. This formatter is used to format
the text output for individual speakers and ensures that the context is clear for the text output for individual speakers and ensures that the context is clear for
@@ -177,6 +179,10 @@ class SpeechmaticsSTTService(STTService):
speaker activity detection. This setting is used only for the formatted text output speaker activity detection. This setting is used only for the formatted text output
of individual segments. of individual segments.
split_sentences: Emit finalized sentences mid-turn. When enabled, as soon as a sentence
is finalized, it will be emitted as a final segment. This is useful for applications
that need to process sentences as they are finalized. Defaults to False.
enable_diarization: Enable speaker diarization. When enabled, the STT engine will enable_diarization: Enable speaker diarization. When enabled, the STT engine will
determine and attribute words to unique speakers. The speaker_sensitivity determine and attribute words to unique speakers. The speaker_sensitivity
parameter can be used to adjust the sensitivity of diarization. parameter can be used to adjust the sensitivity of diarization.
@@ -201,7 +207,7 @@ class SpeechmaticsSTTService(STTService):
language: Language | str = Language.EN language: Language | str = Language.EN
# Endpointing mode # Endpointing mode
turn_detection_mode: TurnDetectionMode = TurnDetectionMode.EXTERNAL turn_detection_mode: TurnDetectionMode = TurnDetectionMode.FIXED
# Output formatting # Output formatting
speaker_active_format: str | None = None speaker_active_format: str | None = None
@@ -230,6 +236,7 @@ class SpeechmaticsSTTService(STTService):
end_of_utterance_max_delay: float | None = None end_of_utterance_max_delay: float | None = None
punctuation_overrides: dict | None = None punctuation_overrides: dict | None = None
include_partials: bool | None = None include_partials: bool | None = None
split_sentences: bool | None = None
# Diarization # Diarization
enable_diarization: bool | None = None enable_diarization: bool | None = None
@@ -326,7 +333,10 @@ class SpeechmaticsSTTService(STTService):
) )
# Framework options # Framework options
self._enable_vad: bool = self._config.end_of_utterance_mode != EndOfUtteranceMode.EXTERNAL self._enable_vad: bool = self._config.end_of_utterance_mode not in [
EndOfUtteranceMode.FIXED,
EndOfUtteranceMode.EXTERNAL,
]
self._speaker_active_format: str = params.speaker_active_format self._speaker_active_format: str = params.speaker_active_format
self._speaker_passive_format: str = ( self._speaker_passive_format: str = (
params.speaker_passive_format or params.speaker_active_format params.speaker_passive_format or params.speaker_active_format
@@ -487,6 +497,7 @@ class SpeechmaticsSTTService(STTService):
"end_of_utterance_max_delay", "end_of_utterance_max_delay",
"punctuation_overrides", "punctuation_overrides",
"include_partials", "include_partials",
"split_sentences",
"enable_diarization", "enable_diarization",
"speaker_sensitivity", "speaker_sensitivity",
"max_speakers", "max_speakers",
@@ -501,6 +512,11 @@ class SpeechmaticsSTTService(STTService):
if hasattr(config, key): if hasattr(config, key):
setattr(config, key, value) setattr(config, key, value)
# Enable sentences
config.speech_segment_config = SpeechSegmentConfig(
emit_sentences=params.split_sentences or False
)
# Return the complete config # Return the complete config
return config return config