microsoft/VibeVoice · error · ValueError

load_audio_bytes_use_ffmpeg requires resample=True

Error message

load_audio_bytes_use_ffmpeg requires resample=True

What it means

load_audio_bytes_use_ffmpeg decodes in-memory audio bytes by piping them through ffmpeg's stdin. Because ffmpeg is invoked with a fixed output sample rate (-ar target_sr), the function cannot honor resample=False — there is no way to probe the original sample rate of an anonymous byte stream without a second ffmpeg pass, so the API rejects the combination up front rather than silently returning wrong-rate audio.

Source

Thrown at vibevoice/processor/audio_utils.py:131

    Parameters
    ----------
    data: bytes
        The audio data bytes
    resample: bool
        Whether to resample the audio (must be True)
    target_sr: int
        The target sample rate if resampling is requested

    Returns
    -------
    A tuple containing:
    - A NumPy array with the audio waveform in float32 dtype
    - The sample rate
    """
    if not resample:
        # For stdin bytes, we don't have a cheap/robust way to probe original sr.
        # Keep behavior explicit.
        raise ValueError("load_audio_bytes_use_ffmpeg requires resample=True")

    cmd = [
        "ffmpeg",
        "-loglevel", "error",
        "-threads", "0",
        "-i", "pipe:0",
        "-f", "s16le",
        "-ac", "1",
        "-acodec", "pcm_s16le",
        "-ar", str(target_sr),
        "-",
    ]
    out = _run_ffmpeg(cmd, stdin_bytes=data).stdout
    audio_data = np.frombuffer(out, np.int16).flatten().astype(np.float32) / 32768.0
    return audio_data, target_sr


class AudioNormalizer:

View on GitHub (pinned to 94da20d98b)

Solutions

  1. Call with resample=True and an explicit target_sr matching your pipeline (e.g. 24000 for VibeVoice).
  2. If you truly need native-rate audio, first write the bytes to a temp file and use the path-based loader that probes the source rate.
  3. Audit wrapper functions so the resample flag is not blindly forwarded to the bytes-based loader.

Example fix

# before
wav, sr = load_audio_bytes_use_ffmpeg(data, resample=False, target_sr=24000)

# after
wav, sr = load_audio_bytes_use_ffmpeg(data, resample=True, target_sr=24000)
Defensive patterns

Strategy: validation

Validate before calling

def load_bytes(data: bytes, target_sr: int = 24000):
    # bytes loader only supports resampling; force it explicitly
    return load_audio_bytes_use_ffmpeg(data, resample=True, target_sr=target_sr)

Try / catch

try:
    wav, sr = load_audio_bytes_use_ffmpeg(data, resample=True, target_sr=24000)
except ValueError as e:
    if 'requires resample=True' in str(e):
        wav, sr = load_audio_bytes_use_ffmpeg(data, resample=True, target_sr=24000)
    else:
        raise

Prevention

When it happens

Trigger: Calling load_audio_bytes_use_ffmpeg(data, resample=False, target_sr=24000) — any call with resample falsy. Typically happens when a generic audio-loading wrapper forwards a user-supplied resample flag to the bytes variant.

Common situations: Code that abstracts over load_audio_from_file (which allows resample=False) and load_audio_bytes_use_ffmpeg passes the same flags to both; users trying to skip resampling for speed when handling uploaded bytes or HTTP responses.

Related errors


AI-assisted analysis of microsoft/VibeVoice@94da20d98b (2026-08-15). Data as JSON: /api/errors/e434f12dc5249a55. Report an issue: GitHub.