#1063·ai-toolkit

Microsoft ADPCM WAVs load at a fraction of their length (audio comes out sped up) through torchaudio.load

Author: Many0therFunctionsCreated Sep 24, 2026Updated Sep 24, 2026

Ran into this with a couple of WAV files that played fine in a normal player but came out way too fast once loaded. Took a while to pin down: the files are fine, the decode isn't.

What happens

Some WAVs are Microsoft ADPCM (format tag 0x0002) rather than plain PCM. Plenty of older tools and some converters still write them. When one goes through torchaudio.load (which decodes via torchcodec now), only a fraction of the samples come back, still labelled with the original sample rate. Nothing errors or warns. The audio just plays back sped up and choppy, and its duration is half or a quarter of what it should be.

From poking at it: the WAV demuxer hands out 4096-byte packets, each holding several ADPCM blocks, and only the first block of each packet survives. A file with 2048-byte blocks comes back at 1/2 length, one with 1024-byte blocks at 1/4. The samples that do come back line up exactly with the real ones, so whole blocks are being dropped, not resampled.

soundfile, PyAV and the ffmpeg CLI all decode the same files correctly.

Repro

bash
ffmpeg -f lavfi -i "sine=frequency=440:duration=10:sample_rate=48000" -ac 2 -c:a adpcm_ms tone_adpcm.wav
python
import torchaudio, soundfile as sf

w, sr = torchaudio.load("tone_adpcm.wav")
print(w.shape[-1] / sr)   # 2.509 s

d, sr = sf.read("tone_adpcm.wav")
print(len(d) / sr)        # 10.015 s

Versions: torch 2.13.0, torchaudio 2.11.0, torchcodec 0.16.0, av 16.0.1, Linux. I haven't tried the torchcodec 0.15.0 that the installer pins, so the snippet above is a quick way to check that one.

Where it hits in ai-toolkit

The one that matters most is the audio dataloader, since it quietly trains on the wrong audio:

The rest decode the same way:

Workarounds

  • Users can convert affected files to PCM or FLAC first, e.g. ffmpeg -i in.wav -c:a pcm_s16le out.wav. soundfile.info(path).subtype reports MS_ADPCM for the affected ones.
  • Decoding through PyAV (already a dependency) or soundfile instead of torchaudio.load returns the full length. The root cause looks like it sits in torchcodec, so it's probably worth a report over there too.