Mintplex-Labs/anything-llm · warning · Error
Audio file exceeds maximum allowed length.
Error message
Audio file exceeds maximum allowed length.
What it means
Second length guard: after upsampling to 16 kHz the projected sample count (duration * 16000) must not exceed 230,400,000. Prevents memory blowup during transcription. In practice it triggers near the same point as error 26 for ~4 h audio.
Source
Thrown at collector/utils/WhisperProviders/localWhisper.js:57
// 4kHz minimum
throw new Error(
"Audio file sample rate is too low for accurate transcription. Minimum required is 4kHz."
);
}
// Typical audio file duration limits
const MAX_DURATION_SECONDS = 4 * 60 * 60; // 4 hours
if (duration > MAX_DURATION_SECONDS) {
throw new Error("Audio file duration exceeds maximum limit of 4 hours.");
}
// Check final sample count after upsampling to prevent memory issues
const targetSampleRate = 16000;
const upsampledSamples = duration * targetSampleRate;
const MAX_SAMPLES = 230_400_000; // ~4 hours at 16kHz
if (upsampledSamples > MAX_SAMPLES) {
throw new Error("Audio file exceeds maximum allowed length.");
}
return true;
}
async #convertToWavAudioData(sourcePath) {
try {
let buffer;
const wavefile = require("wavefile");
const { FFMPEGWrapper } = require("./ffmpeg");
const ffmpeg = new FFMPEGWrapper();
const outFolder = path.resolve(__dirname, `../../storage/tmp`);
if (!fs.existsSync(outFolder))
fs.mkdirSync(outFolder, { recursive: true });
const outputFile = path.resolve(outFolder, `${v4()}.wav`);
const success = await ffmpeg.convertAudioToWav(sourcePath, outputFile);
if (!success)View on GitHub (pinned to 526360e320)
Solutions
- Chunk audio so the upsampled sample count stays under 230.4 M.
- Validate the projection before loading the model.
- Use a streaming/chunked transcription approach for long inputs.
Example fix
// before
const MAX_SAMPLES = 230_400_000;
if (upsampledSamples > MAX_SAMPLES) throw new Error("...maximum allowed length.");
// after — report the projection
if (upsampledSamples > MAX_SAMPLES)
throw new Error(`Projected ${upsampledSamples} samples exceeds ${MAX_SAMPLES}.`); Defensive patterns
Strategy: validation
Validate before calling
function projectedSamples(wav, target = 16000) {
return (wav.data.samples / wav.fmt.sampleRate) * target;
}
// if (projectedSamples(wav) > 230_400_000) chunk the input; Try / catch
try { this.#validateAudioFile(wavFile); }
catch (e) {
if (e.message.includes("maximum allowed length")) { /* split input */ }
throw e;
} Prevention
- Chunk audio to stay under the 4 h / 230 M-sample ceiling.
- Monitor memory when transcribing near the limit.
- Compute the projection before loading the model.
When it happens
Trigger: Long audio whose upsampled footprint would exceed the budget: upsampledSamples = duration * 16000 > 230_400_000.
Common situations: Very long recordings; audio near the 4 h ceiling where the upsample projection tips over the limit.
Related errors
- Audio file duration exceeds maximum limit of 4 hours.
- No base URL was set.
- Audio file sample rate is too low for accurate transcription
- Invalid audio file: ${error.message}
- No OpenAI API key was set.
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/55939947a6ed50dc.
Report an issue: GitHub.