# Test fixtures These files let an implementer (Rust, plain Python, CoreML wrapper, anything) verify two contracts independently: 1. **Audio frontend**: their mel-bank + frame-stack pipeline matches what the upstream `transformers` processor produces. 2. **Encoder graph**: their FP32 ONNX session, run over the verified `input_features`, produces the same `audio_embeds`. ## Files - `sample_audio.wav` - 16 kHz mono float32 PCM, 16.87 s. SHA-256 in `test_fixture.json`. This is the canonical reference clip (`10226_10111_000000.wav` from LibriSpeech). - `expected_input_features.npy` - float32 `[1, 843, 160]`. Mel-bank output after frame-stack: `n_fft=512`, `hop=160`, `win=400`, `n_mels=80`, log10 with -8 dB clamp, no preemphasis, 2-frame stack to 160-dim. - `expected_attention_mask.npy` - int64 `[1, T]` mask for the encoder input. 1 = valid, 0 = padding. Required as a second encoder input. - `expected_audio_embeds.npy` - float32 `[1, 171, 2048]`. The FP32 encoder's output for these input features. - `test_fixture.json` - shapes, sample rate, sha256s, the input mel parameters, tolerance suggestions, sample size in bytes. ## How to use ```python import numpy as np, onnxruntime as ort, soundfile as sf audio, sr = sf.read("test_fixtures/sample_audio.wav", dtype="float32") assert sr == 16000 # 1. Verify your mel/frame-stack pipeline: my_input_features = my_audio_frontend(audio) # float32 [1, T, 160] expected = np.load("test_fixtures/expected_input_features.npy") np.testing.assert_allclose(my_input_features, expected, rtol=1e-3, atol=1e-4) # 2. Verify the encoder runs identically on identical inputs: sess = ort.InferenceSession("fp32/encoder.onnx", providers=["CPUExecutionProvider"]) embeds = sess.run(["audio_embeds"], {"input_features": expected, "attention_mask": expected_attention_mask})[0] np.testing.assert_allclose( embeds, np.load("test_fixtures/expected_audio_embeds.npy"), rtol=1e-4, atol=1e-5, ) ``` INT8 and FP16w runs will not pass `assert_allclose` against the FP32 fixture within the tolerances above. For those tiers, compare your runtime against the FP32 ONNX run on the same machine: drift comes from kernel choice and acceleration backend, not from a stale fixture.