Skip to content

Commit dc17984

Browse files
authored
Fix Gemma 4 audio processor operation (#752)
## Summary - emit the registered `Gemma4LogMel` operation for standard Gemma 4 audio preprocessing - remove the unsupported `type=log_mel` operation attribute - update the generated-config expectations ## Testing - Not run (per request).
1 parent c2fde93 commit dc17984

2 files changed

Lines changed: 6 additions & 9 deletions

File tree

‎src/mobius/integrations/ort_genai/auto_export.py‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,7 @@ def _write_audio_processor_config(
13841384
proc_filename = "audio_feature_extraction.json"
13851385
elif model_type in _GEMMA4_MODEL_TYPES:
13861386
# Gemma4 USM-style 128-dim log-mel spectrogram via the ort-extensions
1387-
# ``Gemma4Audio`` op with ``type="log_mel"``.
1387+
# ``Gemma4LogMel`` op.
13881388
# OrtxCreateSpeechFeatureExtractor requires the feature_extraction.sequence format.
13891389
processor = {
13901390
"feature_extraction": {
@@ -1397,10 +1397,9 @@ def _write_audio_processor_config(
13971397
},
13981398
{
13991399
"operation": {
1400-
"name": "gemma4_audio",
1401-
"type": "Gemma4Audio",
1400+
"name": "gemma4_log_mel",
1401+
"type": "Gemma4LogMel",
14021402
"attrs": {
1403-
"type": "log_mel",
14041403
"feature_size": 128,
14051404
"sampling_rate": 16000,
14061405
"frame_length_ms": 20.0,

‎src/mobius/integrations/ort_genai/auto_export_test.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,9 +1029,8 @@ def test_audio_gemma4_writes_feature_extraction_json(self, tmp_path):
10291029
seq = data["feature_extraction"]["sequence"]
10301030
assert len(seq) == 2
10311031
assert seq[0]["operation"]["type"] == "AudioDecoder"
1032-
assert seq[1]["operation"]["type"] == "Gemma4Audio"
1032+
assert seq[1]["operation"]["type"] == "Gemma4LogMel"
10331033
attrs = seq[1]["operation"]["attrs"]
1034-
assert attrs["type"] == "log_mel"
10351034
assert attrs["feature_size"] == 128
10361035
assert attrs["sampling_rate"] == 16000
10371036
assert attrs["frame_length_ms"] == 20.0 # noqa: RUF069
@@ -1968,10 +1967,9 @@ class FakeConfig:
19681967
op0 = seq[0]["operation"]
19691968
assert op0["type"] == "AudioDecoder"
19701969

1971-
# Second op: Gemma4Audio (type=log_mel) with expected attrs
1970+
# Second op: Gemma4LogMel with expected attrs
19721971
op1 = seq[1]["operation"]
1973-
assert op1["type"] == "Gemma4Audio"
1974-
assert op1["attrs"]["type"] == "log_mel"
1972+
assert op1["type"] == "Gemma4LogMel"
19751973
assert op1["attrs"]["feature_size"] == 128
19761974
assert op1["attrs"]["sampling_rate"] == 16000
19771975
assert op1["attrs"]["mel_floor"] == 0.001 # noqa: RUF069

0 commit comments

Comments
 (0)