From 9daf0e3b4f8811f40a4a3df7f13a717418421bcd Mon Sep 17 00:00:00 2001 From: hailin Date: Tue, 3 Mar 2026 01:04:20 -0800 Subject: [PATCH] fix: bypass LanguageCode normalization that maps cmn back to zh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- packages/services/voice-agent/src/plugins/speechmatics_stt.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/services/voice-agent/src/plugins/speechmatics_stt.py b/packages/services/voice-agent/src/plugins/speechmatics_stt.py index edcf9cb..6219073 100644 --- a/packages/services/voice-agent/src/plugins/speechmatics_stt.py +++ b/packages/services/voice-agent/src/plugins/speechmatics_stt.py @@ -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