Repository navigation
fix(asr): reject an unsupported onnx-genai language instead of decoding it as English - #96
Merged
Merged
Conversation
jedzill4
force-pushed
the
feat/canonical-language-hint
branch
from
October 7, 2026 16:15
805a26c to
2e3c9fa
Compare
…ng it as English _lang_id_for fell back to English for any language the model does not list, and matched case-sensitively, so xx and even ES-es returned an English transcript of the audio with no error. It now matches the canonical spelling (exact locale, then base language) and raises AsrUnsupportedLanguageError, which every API surface reports as a 400 naming the supported set. No language still keeps the English default.
jedzill4
force-pushed
the
fix/onnx-genai-unsupported-language
branch
from
October 7, 2026 16:20
f46774c to
1f3f392
Compare
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.
Stacked on #95 (base
feat/canonical-language-hint, which itself sits on #92); retarget tomainas the stack merges.Problem
onnx-genai's_lang_id_forreturned the Englishlang_idfor any language the model does not list, and matched case-sensitively. Solanguage=xx, and evenES-es, produced an English decode of the audio with HTTP 200: a wrong transcript with no error.Change (behaviour change, agreed with the maintainer)
_lang_id_formatches the canonical spelling (#95): exact locale first, then base language (es-AR->es), and otherwise raisesAsrUnsupportedLanguageError(canonical, supported_languages=<model's languages>), which the OpenAI, SSE and Deepgram surfaces already report as a 400 withparam=language. The check runs before the request takes an admission slot or touches the model. No language (None/blank) still keeps the English default.What now fails that used to "work": a client sending a language outside the model's 40 locales used to get an English transcript; it now gets a 400 listing the supported set.
Tests (test-first)
tests/backends/asr/test_onnx_genai_backend.py:_lang_id_for("xx") == 0now requiresAsrUnsupportedLanguageErrorcarrying the language and supported set.ES-es-> 2 anden_gb-> 1 (both silently decoded as English before).transcribe_pcm(language="xx-YY")raises before reaching the model (object()stands in for it).es-AR->es,None/""-> English default unchanged.Local: 532 passed, 9 skipped (
tests/backends,tests/api); the full prek suite passed on commit, pyrefly included.Not verified
_lang_id_foris pure string/dict logic and the adapter test stops before the model.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.