unslothai/unsloth · error · ValueError
MiniMax-H3 reference audio runs up to {H3_REF_VIDEO_MAX_SECO
Error message
MiniMax-H3 reference audio runs up to {H3_REF_VIDEO_MAX_SECONDS:g} seconds; this one is longer. Trim it first. What it means
Inside _decode_audio_stream, the _take callback accumulates resampled samples and raises ValueError once total exceeds max_samples = floor(H3_REF_VIDEO_MAX_SECONDS * sample_rate + 1e-6), i.e. the audio runs past the model's 15s reference window. The check is incremental during decode because encoded size says nothing about decoded size (a 32 MiB MP3 can be over half an hour), so refusing early avoids building a multi-GB float32 array only to reject it. Uses the same message family as the video-path guards.
Source
Thrown at studio/backend/core/inference/video_minimax_h3.py:476
``H3_REF_VIDEO_MAX_SECONDS`` anyway, so anything past it is unusable rather than merely large:
refuse it with the same message the video guard uses instead of decoding it first."""
import av
stream = container.streams.audio[0]
sample_rate = int(stream.codec_context.sample_rate or 48_000)
# One resampler pass gives interleaved float32 whatever the source layout/format was.
resampler = av.AudioResampler(format = "flt", layout = stream.layout.name, rate = sample_rate)
channels = len(stream.layout.channels)
max_samples = math.floor(H3_REF_VIDEO_MAX_SECONDS * sample_rate + 1e-6)
chunks = []
total = 0
def _take(resampled: Any) -> None:
nonlocal total
block = resampled.to_ndarray().reshape(-1, channels)
total += block.shape[0]
if total > max_samples:
raise ValueError(
f"MiniMax-H3 reference audio runs up to {H3_REF_VIDEO_MAX_SECONDS:g} seconds; "
f"this one is longer. Trim it first."
)
chunks.append(block)
for frame in container.decode(audio = 0):
for resampled in resampler.resample(frame):
_take(resampled)
for resampled in resampler.resample(None):
_take(resampled)
if not chunks:
return None, None
return np.concatenate(chunks, axis = 0).astype("float32"), sample_rate
def write_h3_reference_wav(path: Path, waveform: Any, sample_rate: int) -> None:
"""Write a reference waveform as the 16-bit PCM WAV sd-cli's --ref-audio loader reads."""
import waveView on GitHub (pinned to 203007d190)
Solutions
- Trim the audio to at most 15s before upload: ffmpeg -ss 30 -t 10 -i song.mp3 ref.mp3.
- Show the 15s cap in the upload UI and validate duration client-side.
- Extract just the segment aligned with the video reference if you are building AV-conditioned generations.
Example fix
# before: whole 3-minute track -> ValueError
upload_audio_reference(open("song.mp3", "rb").read())
# after: cut the 10s hook
ffmpeg -ss 42 -t 10 -i song.mp3 -c:a libmp3lame ref.mp3 Defensive patterns
Strategy: validation
Validate before calling
import av, io, math
H3_REF_VIDEO_MAX_SECONDS = 15.0
with av.open(io.BytesIO(blob)) as c:
s = c.streams.audio[0]
rate = s.rate or s.codec_context.sample_rate
samples = s.duration or 0 # stream duration is in samples for audio
if samples and samples / rate > H3_REF_VIDEO_MAX_SECONDS:
raise ValueError("trim reference audio to <= 15s") Try / catch
try:
wf, sr = decode_h3_reference_audio(blob)
except ValueError as e:
if "reference audio runs up to" in str(e):
return HTTPException(400, "trim the audio to at most 15s") from e
raise Prevention
- Trim audio to <= 15s (same window as video references) before upload.
- Never assume request-size limits imply duration limits — MP3 expands ~60x decoded.
- Extract the exact snippet matching the video reference segment when conditioning A/V together.
When it happens
Trigger: Uploading a full song or podcast episode as an H3 audio reference; a 30-minute 32 MiB MP3 (the request-limit-sized example from the code); any audio whose duration exceeds 15s.
Common situations: Users supplying whole tracks instead of the relevant snippet; pipelines passing untrimmed voice-over masters; assuming the request size limit implies a duration limit.
Related errors
- MiniMax-H3 reference videos run {H3_REF_VIDEO_MIN_SECONDS:g}
- MiniMax-H3 reference videos run {H3_REF_VIDEO_MIN_SECONDS:g}
- That reference file carries no audio track.
- That reference audio decoded to no samples.
- Audio must be {max_minutes} {unit} or shorter.
AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15).
Data as JSON: /api/errors/687bf7908ab5dd29.
Report an issue: GitHub.