feat(speechmatics): expose end_of_turn_config and vad_config STT options - #6925
Open
saad-py wants to merge 1 commit into
Open
feat(speechmatics): expose end_of_turn_config and vad_config STT options#6925saad-py wants to merge 1 commit into
saad-py wants to merge 1 commit into
Conversation
In ADAPTIVE and SMART_TURN modes the effective end-of-turn wait is end_of_utterance_silence_trigger multiplied by EndOfTurnConfig penalty multipliers, with VoiceActivityConfig driving when predictions are scheduled. Neither object was reachable through the plugin, so the hardcoded defaults (x0.2 on VAD stop, 0.18s VAD silence, 0.01s floor) could not be tuned: any configured trigger collapses to a ~60-240ms effective wait, splitting phone callers' sentences on natural pauses. Pass both through the existing preset-override mechanism as typed, optional kwargs. Omitted kwargs leave preset behavior unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #6924
Problem
In
ADAPTIVEandSMART_TURNmodes, the effective end-of-turn wait is not the configuredend_of_utterance_silence_trigger: it is the trigger multiplied by theEndOfTurnConfigpenalty table, minus recent TTFB, floored atmin_end_of_turn_delay(speechmatics.voice._client.VoiceAgentClient._calculate_finalize_delay). The SDK-default penalties make this collapse far below any configured value:speech_endedafter only 0.18s of silence (VoiceActivityConfig.silence_durationdefault).ADAPTIVE), every VAD stop matches theVAD_STOPPED + SMART_TURN_INACTIVEpenalty: ×0.2.ENDS_WITH_FINAL + ENDS_WITH_EOS: ×0.5, and simultaneously loses the ×2.0 "not end-of-sentence" protection.With
end_of_utterance_silence_trigger=0.6, the effective wait after the VAD fires is0.6 × 0.2 × 0.5 = 0.06s(punctuated) or0.6 × 0.2 × 2.0 = 0.24s(unpunctuated), then floored as low asmin_end_of_turn_delay=0.01safter TTFB subtraction. Total real-world pause tolerance is roughly 0.25-0.45s, regardless of the configured trigger (even 1.5s yields ≤0.6s). On telephony this splits normal mid-sentence pauses (a caller recalling a date of birth or spelling out an email address) into multiple committed user turns, with the agent replying to each fragment.Because the trigger only scales the base linearly, no currently exposed plugin parameter can prevent this:
EndOfTurnConfigandVoiceActivityConfigare not in the constructor and not in_prepare_config()'sadvanced_paramswhitelist.Change
Expose both objects through the existing preset-override mechanism, exactly like the other advanced parameters:
STT(...)gains typed optional kwargsend_of_turn_config: NotGivenOr[EndOfTurnConfig]andvad_config: NotGivenOr[VoiceActivityConfig](both types are already public exports ofspeechmatics-voice, which this plugin already depends on).STTOptionsand added to theadvanced_paramswhitelist in_prepare_config(), so a provided value replaces the preset's object entirely and an omitted kwarg changes nothing.No behavior change for existing users: both kwargs default to
NOT_GIVEN.Usage example
Testing
tests/test_plugin_speechmatics_stt.py(markedpytest.mark.plugin("speechmatics"), hermetic, no network):test_end_of_turn_config_passthrough: a providedEndOfTurnConfigreaches the preparedVoiceAgentConfig.test_vad_config_passthrough: same forVoiceActivityConfig.test_preset_defaults_kept_when_not_given: omitting both kwargs leaves the ADAPTIVE preset's values untouched.ruff checkandruff formatpass on both files.Notes
Happy to adjust the API shape if maintainers prefer granular kwargs over passing the config objects.