bug(transcription): whisper decoder ONNX Reshape error with language="fr"
Description
With the built-in Whisper backend (model="base", language="fr"), transcribing a long real-world recording aborts the whole extraction with an ONNX Runtime Reshape error in the decoder. A single failing 30-second window is enough: no text is returned for the entire file (1 h 39 min here).
Expected: the transcription completes. If a window cannot be decoded, at worst that window yields no text (ideally with a warning), instead of the whole file failing.
Error:
RuntimeError: Transcription error: whisper inference failed: ONNX Runtime error: Non-zero status code returned while running Reshape node. Name:'/model/decoder/layers.0/self_attn/Reshape_6' Status Message: E:_work\1\s\onnxruntime\core\providers\cpu\tensor\reshape_helper.h:47 onnxruntime::ReshapeHelper::ReshapeHelper input_shape_size == size was false. The input tensor cannot be reshaped to the requested shape. Input shape:{8,0,64}, requested shape:{1,8,64,64}
Findings on the real-world file (cannot be shared):
- Deterministic: fails 2 runs out of 2, always after about 4 minutes of processing.
- Not the container: the same audio decoded to PCM WAV fails; the AAC track alone without video (stream copy to .m4a) fails.
- Local trigger: split into 60-second pieces transcribed one by one, 4 of 99 pieces fail; the other 95 transcribe normally.
- Not silence: failing pieces have the same audio profile as working ones (continuous speech, about -24 dBFS, about 8 % of 100 ms frames below -50 dBFS, longest pause under 1 s).
- Language-dependent: each of the 4 failing 60-second pieces transcribes fine with language auto-detection.
- Timing clue: failing 30-second windows take about 28 s before the error, versus 9-11 s for working windows (synthetic clip: about 23 s versus 3-5 s). This suggests the decoder keeps generating (e.g. a repetition loop) until some length limit, where the self-attention cache ends up empty. This is an assumption; we have not inspected the decoding loop. It may relate to the hand-written Whisper decode loop and its KV-cache handling mentioned in #1385.
We set the language explicitly, as recommended for determinism in #487.
Failing 60 s pieces, narrowed to 30 s windows (language="fr"):
- 11:00-12:00 auto-detect OK | 0-30 s OK, 15-45 s OK, 30-60 s FAIL
- 43:00-44:00 auto-detect OK | 0-30 s OK, 15-45 s OK, 30-60 s FAIL
- 47:00-48:00 auto-detect OK | 0-30 s FAIL, 15-45 s FAIL, 30-60 s OK
- 1:09:00-1:10:00 auto-detect OK | 0-30 s FAIL, 15-45 s OK, 30-60 s OK
Steps to reproduce
Synthetic reproduction attached (repro_synthetique.zip: espeak-ng speech and generated audio only, plus a standalone repro.py).
- pip install xberg==1.2.9
- Place the Whisper base model cache (onnx-community/whisper-base @ 1846881b6b3a3024392c1eea3ad983695bc23925) in <model_cache_dir>
- HF_HUB_OFFLINE=1 python repro.py clip_30s_fails.wav <model_cache_dir> fr -> fails with the Reshape error above
Results:
- clip_30s_fails.wav (30 s, 16 kHz mono), language="fr": FAIL on 1.2.8 and 1.2.9
- clip_30s_fails.wav, language="en": OK (1.2.9)
- clip_30s_fails.wav, auto-detect: OK (1.2.9)
- clip_30s_before_aac_ok.wav (same 30 s before AAC encoding), language="fr": OK (1.2.9)
- long_mixed_12min.mp4 (H.264 + AAC LC), language="fr": FAIL on 1.2.8 (2/2 runs) and 1.2.9
The synthetic results are identical on Linux x86_64 and Windows 11 (xberg 1.2.8).
Relevant files and configuration
ExtractionConfig(output_format="markdown", use_cache=False, disable_ocr=True,
transcription=TranscriptionConfig(enabled=True, model="base", model_cache_dir=CACHE,
allow_network=False, verify_hash=False, language="fr",
max_duration_ms=3*3600*1000, max_bytes=2*1024**3, timeout_ms=4*3600*1000))
Environment
- Real-world file: Windows 11 (10.0.26200), AMD Ryzen 5 3600X (12 logical cores), 32 GiB RAM, Python 3.13.13, xberg 1.2.8 (PyPI wheel)
- Synthetic files: same Windows machine (xberg 1.2.8), and Linux x86_64, Python 3.13 (xberg 1.2.8 and 1.2.9)
- Model: onnx-community/whisper-base @ 1846881b6b3a3024392c1eea3ad983695bc23925, loaded offline from a local cache (HF_HUB_OFFLINE=1)
- The real-world file was not tested with xberg 1.2.9; the synthetic clip fails identically on 1.2.9.
Real-world input (technical characteristics only)
- MP4, 823 MiB, 1 h 38 min 58 s
- Audio: AAC LC, 44.1 kHz, stereo, 128 kbit/s
- Video: H.264 High, 1920x1080, 25 fps
- Also contains a mov_text subtitle trackSource: xberg-io/xberg