Repository navigation
fix(google): validate the STT adaptation before applying update_options - #8172
Open
ShivamSharma43 wants to merge 1 commit into
Open
ShivamSharma43 wants to merge 1 commit into
ShivamSharma43 wants to merge 1 commit into
Conversation
STT.update_options applied languages, detect_language, interim_results, punctuate, spoken_punctuation and profanity_filter before checking that the adaptation fits the model's API version. A rejected adaptation (or a model switch the current adaptation doesn't fit) raised ValueError with those options already changed on the STT, so later streams used them although the call failed. Resolve and validate the adaptation first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Problem
google.STT.update_optionsassignslanguages,detect_language,interim_results,punctuate,spoken_punctuationandprofanity_filterfirst, and only then checks that the adaptation fits the model's API version:The call raises, but the STT now has
languages == ["fr-FR"]andpunctuate == False. Streams opened afterwards use them, although the caller was told the update failed. A model switch that the current adaptation doesn't fit leaves the same partial state (for example,update_options(model="long", languages="de-DE")on a STT that holds a v2 adaptation).Fix
update_optionsnow resolves the target API version and validates the adaptation before it assigns anything. Nothing else changes: the same calls are accepted, the error messages are the same, and open streams are updated only after the checks pass, as before.Tests
Two tests added to
tests/test_plugin_google_stt.py:test_update_options_rejected_adaptation_changes_nothing: a v1 adaptation on chirp_3, passed with every option assigned before the check, leaves all of them unchanged.test_update_options_rejected_model_switch_keeps_languages: switching to a v1 model while a v2 adaptation is set leaves the languages,punctuateand the model unchanged.Both fail on
main.🤖 Generated with Claude Code