Skip to content

fix(asr): reject an unsupported onnx-genai language instead of decoding it as English - #96

Merged
jedzill4 merged 1 commit into
mainfrom
fix/onnx-genai-unsupported-language
Oct 7, 2026
Merged

jedzill4 merged 1 commit into
mainfrom
fix/onnx-genai-unsupported-language

Conversation

@jedzill4

@jedzill4 jedzill4 commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #95 (base feat/canonical-language-hint, which itself sits on #92); retarget to main as the stack merges.

Problem

onnx-genai's _lang_id_for returned the English lang_id for any language the model does not list, and matched case-sensitively. So language=xx, and even ES-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_for matches the canonical spelling (#95): exact locale first, then base language (es-AR -> es), and otherwise raises AsrUnsupportedLanguageError(canonical, supported_languages=<model's languages>), which the OpenAI, SSE and Deepgram surfaces already report as a 400 with param=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:

  • The test that pinned _lang_id_for("xx") == 0 now requires AsrUnsupportedLanguageError carrying the language and supported set.
  • ES-es -> 2 and en_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


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@jedzill4
jedzill4 force-pushed the feat/canonical-language-hint branch from 805a26c to 2e3c9fa Compare October 7, 2026 16:15
…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
jedzill4 force-pushed the fix/onnx-genai-unsupported-language branch from f46774c to 1f3f392 Compare October 7, 2026 16:20
@jedzill4
jedzill4 changed the base branch from feat/canonical-language-hint to main October 7, 2026 16:20
@jedzill4
jedzill4 merged commit dae58d6 into main Oct 7, 2026
3 checks passed
@jedzill4
jedzill4 deleted the fix/onnx-genai-unsupported-language branch October 8, 2026 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant