fix: bypass LanguageCode normalization that maps cmn back to zh

LiveKit's LanguageCode class normalizes ISO 639-3 codes to ISO 639-1
(cmn → zh), but Speechmatics API expects "cmn" not "zh". Override
the internal _stt_options.language after construction.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-03-03 01:04:20 -08:00
parent 7292ac6ca6
commit 9daf0e3b4f
1 changed files with 4 additions and 0 deletions

View File

@ -40,5 +40,9 @@ def create_speechmatics_stt(language: str = "cmn") -> speechmatics.STT:
language=sm_lang,
include_partials=True,
)
# Workaround: LiveKit's LanguageCode normalizes ISO 639-3 "cmn" back to
# ISO 639-1 "zh", but Speechmatics expects "cmn". Override the internal
# option after construction so the raw Speechmatics code is sent.
stt._stt_options.language = sm_lang # type: ignore[assignment]
logger.info("Speechmatics STT created: language=%s (input=%s)", sm_lang, language)
return stt