Skip to content

AudioProcessor resample silently corrupts long compressed audio (87-min mp3 → garbage transcript, exit 0) #500

Description

@kiki830621

Summary

AudioProcessor's resample path silently produces corrupted PCM for long compressed audio files: an 87-minute 44.1 kHz stereo mp3 transcribes to garbage (a single "(music)"-style cue / a 129 KB blob of repeated tokens) with exit code 0 — no error surfaces anywhere. The same pipeline handles short slices of the same file and 16 kHz mono WAV of any length correctly, which is what makes this dangerous: it looks like a model-quality problem, not an audio-decoding one.

Reproduction matrix (WhisperKit 0.18.0, Apple Silicon, macOS 27)

Input Result
87-min 44.1 kHz stereo mp3 ❌ corrupted transcript (garbage tokens), exit 0
first 5-min slice of the SAME mp3 ✅ normal transcript
same 87-min audio pre-converted to 16 kHz mono WAV ✅ normal transcript
any-length 16 kHz mono WAV ✅ normal transcript

Audio used: the public Jobs/Gates D5 conversation recording (any long compressed file should do; the failure threshold between 5 and 87 minutes was not bisected).

Suspected mechanism (not bisected upstream)

Two candidate contributors in the 0.18.0 resample path (AudioProcessor.swift around lines 381–450):

  1. The path trusts the compressed container's estimated AVAudioFile.length when sizing reads — for VBR mp3 the estimate can diverge from the real frame count.
  2. Resampling happens in chunks (the 10 MB chunking introduced in the old WhisperKit issue tracker as "Resample audio files in 10mb chunks"), and the AVAudioConverter appears to be rebuilt per chunk — a fresh converter loses filter state across chunk boundaries, which corrupts the signal cumulatively on long files while staying inaudible/harmless on short ones.

Related (closed) reports in the old tracker were about explicit failures (resampleBuffer capacity, "Failed to process audio buffer" for an mp3); this one is nastier because nothing fails — the decoded PCM is simply wrong.

Workaround we ship

Pre-convert every input to 16 kHz mono WAV via a single long-lived AVAudioConverter before it reaches WhisperKit; the corruption never reproduces through that path. Happy to test a fix against the same 87-minute file.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions