mudler/LocalAI · error · ValueError

audio contains no samples

Error message

audio contains no samples

What it means

ValueError after librosa.load(request.audio, sr=16000, mono=True) returns an empty array (speech.size == 0). The file existed but decoded to zero samples — typically a zero-byte or header-only audio file, or one ffmpeg/soundfile silently decodes to nothing. Duration math (len(speech)/sample_rate) would be nonsensical, so generation aborts.

Source

Thrown at backend/python/longcat-video/backend.py:653

        )
        audio_guidance = (
            1.0
            if use_distill
            else require_float(
                params.get("audio_guidance_scale", 4.0),
                "audio_guidance_scale",
                minimum=0.0,
                maximum=20.0,
            )
        )
        seed = request.seed if request.seed > 0 else 42
        generator = self.torch.Generator(device=self.device_index).manual_seed(seed)
        negative_prompt = request.negative_prompt or DEFAULT_NEGATIVE_PROMPT
        resolution = self._resolution(params)

        speech, sample_rate = self.librosa.load(request.audio, sr=16000, mono=True)
        if speech.size == 0:
            raise ValueError("audio contains no samples")
        audio_duration = len(speech) / sample_rate
        segments = self._avatar_segments(request, params, audio_duration)

        segment_frames = 93
        conditioning_frames = 13
        avatar_fps = 25
        generated_duration = (
            segment_frames + (segments - 1) * (segment_frames - conditioning_frames)
        ) / avatar_fps
        pad_samples = max(
            0, math.ceil((generated_duration - audio_duration) * sample_rate)
        )
        if pad_samples:
            speech = self.np.pad(speech, (0, pad_samples))

        full_audio_embedding = self.pipeline.get_audio_embedding(
            speech,
            fps=avatar_fps,

View on GitHub (pinned to 44413a9d06)

Solutions

  1. Inspect the file on the backend host: ffprobe /path/audio to confirm it has an audio stream with duration > 0
  2. Re-export or regenerate the audio, then re-stage and retry
  3. Add a client-side sanity check that the file size and decoded duration are non-zero before sending

Example fix

# before
# staged file was truncated during upload

# after
import subprocess
 subprocess.run(["ffmpeg","-y","-i","raw.webm","/data/staged/voice.wav"], check=True)  # full re-encode, verify with ffprobe
Defensive patterns

Strategy: validation

Validate before calling

import os, subprocess, json

def audio_has_samples(path: str, min_seconds: float = 0.1) -> bool:
    if not os.path.isfile(path) or os.path.getsize(path) == 0:
        return False
    out = subprocess.run(
        ["ffprobe", "-v", "error", "-show_entries", "format=duration",
         "-of", "json", path], capture_output=True, text=True)
    if out.returncode != 0:
        return False
    try:
        return float(json.loads(out.stdout)["format"]["duration"]) >= min_seconds
    except (KeyError, ValueError):
        return False

Try / catch

try:
    stub.GenerateVideo(req)
except grpc.RpcError as e:
    if "no samples" in (e.details() or ""):
        raise UserError("Audio file is empty or unreadable; re-export it") from e
    raise

Prevention

When it happens

Trigger: Uploading a 0-byte or truncated wav/mp3; a file with valid container headers but no audio frames; a codec mismatch where the decoder finds no audio stream.

Common situations: Upload pipeline truncated the file; TTS step produced an empty output that was passed straight to video generation; wrong file extension (e.g. .wav containing text).

Related errors


AI-assisted analysis of mudler/LocalAI@44413a9d06 (2026-08-15). Data as JSON: /api/errors/bdf13ac0e5d80781. Report an issue: GitHub.