Skip to content

Commit 69cb590

Browse files
justinchubyCopilot
andcommitted
Add ctc-asr task_type + generation.lang to YAML schema
- testdata/cases/schema.json: register 'ctc-asr' in the task_type enum and add 'lang' under generation properties so the new mms-1b-all case validates. yaml_schema_test now passes (225/225). - Drop suppressible try/except in _generate_ctc_asr (RUFF/SIM105) in favour of contextlib.suppress. - Ruff-format blank line in _registry.py. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Justin Chu <11205048+justinchuby@users.noreply.github.com>
1 parent b598291 commit 69cb590

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

scripts/generate_golden.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from __future__ import annotations
3939

4040
import argparse
41+
import contextlib
4142
import fnmatch
4243
import sys
4344
import time
@@ -838,13 +839,11 @@ def _generate_ctc_asr(case: TestCase, json_path: Path, device: str) -> None:
838839
ignore_mismatched_sizes=True, # MMS lm_head shape changes per language
839840
)
840841
# For MMS, switching languages also requires loading the per-language adapter.
842+
# Non-MMS Wav2Vec2ForCTC checkpoints don't have language adapters;
843+
# the missing-adapter case is expected and harmless there.
841844
if hasattr(model, "load_adapter"):
842-
try:
845+
with contextlib.suppress(ValueError, KeyError, OSError):
843846
model.load_adapter(lang)
844-
except (ValueError, KeyError, OSError):
845-
# Non-MMS Wav2Vec2ForCTC checkpoints don't have language adapters;
846-
# the missing-adapter case is expected and harmless there.
847-
pass
848847
model.eval()
849848

850849
audio_path = Path("testdata") / case.audio[0]

src/mobius/_registry.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,7 @@ def _detect_fallback_registration(hf_config) -> ModelRegistration | None:
666666
"mms": ModelRegistration(Wav2Vec2ForCTCModel, task="ctc-asr", config_class=MMSConfig),
667667
}
668668

669+
669670
def _create_default_registry() -> ModelRegistry:
670671
"""Create the default registry with all built-in architectures."""
671672
reg = ModelRegistry()

testdata/cases/schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"audio-feature-extraction",
4545
"audio-to-audio",
4646
"codec",
47+
"ctc-asr",
4748
"depth-estimation",
4849
"feature-extraction",
4950
"fun-asr-speech-language",
@@ -131,6 +132,10 @@
131132
"eos_token_id": {
132133
"type": "integer",
133134
"description": "End-of-sequence token ID. Overrides the model's default to ensure generation stops correctly."
135+
},
136+
"lang": {
137+
"type": "string",
138+
"description": "Target language code for multilingual models (e.g. MMS uses ISO-639-3 codes like 'eng' to pick the per-language adapter)."
134139
}
135140
},
136141
"additionalProperties": false,

0 commit comments

Comments
 (0)