Repository navigation
Conversation
- In TTS.__init__, allow language=None without raising AttributeError/ValueError, leaving language to the server default (matching update_options(language=None)). - In STT.__init__, treat language_code=None and language_codes=None as unset (NOT_GIVEN) rather than raising ValueError on non-U3-Pro models or TypeError in normalization. - In STT and SpeechStream update_options, allow language_codes=None to clear language steering (normalized to []), matching [] and "". - Add test coverage in test_plugin_assemblyai_tts.py and test_plugin_assemblyai_stt.py.
|
|
| if is_given(language_code) and not language_code: | ||
| language_code = NOT_GIVEN | ||
| if is_given(language_codes) and not language_codes: | ||
| language_codes = NOT_GIVEN |
There was a problem hiding this comment.
🟡 Unset language blocks valid steering
With language_code=None and language_codes=['es'], STT raises a mutual-exclusion error before clearing the unset value. The reverse combination fails too, so callers passing both optional fields cannot select a language.
Learn more
The constructor treats None as an unset language option, but its mutual-exclusion check runs before these two normalization lines. is_given(None) is true, so an explicitly unset field triggers the check when the other field has a real value. The same mismatch applies in either argument order. The check and the new normalization must use the same meaning of unset.
Example: STT(api_key="k", language_code=None, language_codes=["es"]) raises ValueError instead of storing ["es"] in _opts.language_codes.
Recommended fix: Normalize both empty or None language arguments to NOT_GIVEN before the mutual-exclusion check in STT.__init__; retain the error when both normalized arguments contain actual codes.
Was this helpful? React with 👍 or 👎 to provide feedback.
Problem
TTS(language=None)crashes: InTTS.__init__,languagewas typedNotGivenOr[str]and processed via_language_name(language) if is_given(language) else None. When a caller explicitly passedlanguage=None(e.g., from an agent configuration dictionary or factory defaulting optional arguments toNone),is_given(None)evaluated toTrue, passingNoneto_language_namewhich calledNone.strip()and raisedAttributeError/ValueError: language cannot be empty. This was also inconsistent withTTS.update_options(language=None), which explicitly supportsNoneto reset back to the server's default language.STT(language_codes=None)andSTT(language_code=None)crashes: InSTT.__init__, an explicitlanguage_codes=Noneorlanguage_code=Nonefailed the_U3_PRO_MODELScheck on non-U3-Pro models (becauseis_given(None)isTrue), and for U3-Pro models_normalize_language_codesattempted to iterate overNone(for code in language_codes), raisingTypeError: 'NoneType' object is not iterable.update_options(language_codes=None)crashes: Callingupdate_options(language_codes=None)onSTTorSpeechStreampassedNonedirectly into_normalize_language_codes, raisingTypeError: 'NoneType' object is not iterableinstead of clearing steering (normalized to[]), unlike""or[].Changes
languageparameter asNotGivenOr[str | None] = NOT_GIVENinTTS.__init__._language_name(language)withif is_given(language) and language is not None else Noneso explicitNoneleaves language to the server default (matchingupdate_options(language=None)).language_codeandlanguage_codesparameter types to acceptNoneinSTT.__init__,STT.update_options, andSpeechStream.update_options._normalize_language_codes, return[]whenlanguage_codes is None(matching""and[]).STT.__init__, treatlanguage_codeandlanguage_codesasNOT_GIVENwhen empty (includingNone), keeping them exempt from the non-U3-Pro model gate at construction.tests/test_plugin_assemblyai_tts.pyverifyingTTS(language=None)leaves_opts.languageasNone.tests/test_plugin_assemblyai_stt.pyverifyingSTT(language_codes=None),STT(language_code=None), andupdate_options(language_codes=None)behave as unset/cleared steering.Testing
uv run pytest tests/test_plugin_assemblyai_tts.py tests/test_plugin_assemblyai_stt.py(178 passed).uv run ruff checkanduv run ruff format --check(clean).uv run mypy livekit-plugins/livekit-plugins-assemblyai/(0 issues in 5 source files).