{"record":{"id":"55939947a6ed50dc","repo":"Mintplex-Labs/anything-llm","slug":"audio-file-exceeds-maximum-allowed-length","errorCode":null,"errorMessage":"Audio file exceeds maximum allowed length.","messagePattern":"Audio file exceeds maximum allowed length\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"collector/utils/WhisperProviders/localWhisper.js","lineNumber":57,"sourceCode":"      // 4kHz minimum\n      throw new Error(\n        \"Audio file sample rate is too low for accurate transcription. Minimum required is 4kHz.\"\n      );\n    }\n\n    // Typical audio file duration limits\n    const MAX_DURATION_SECONDS = 4 * 60 * 60; // 4 hours\n    if (duration > MAX_DURATION_SECONDS) {\n      throw new Error(\"Audio file duration exceeds maximum limit of 4 hours.\");\n    }\n\n    // Check final sample count after upsampling to prevent memory issues\n    const targetSampleRate = 16000;\n    const upsampledSamples = duration * targetSampleRate;\n    const MAX_SAMPLES = 230_400_000; // ~4 hours at 16kHz\n\n    if (upsampledSamples > MAX_SAMPLES) {\n      throw new Error(\"Audio file exceeds maximum allowed length.\");\n    }\n\n    return true;\n  }\n\n  async #convertToWavAudioData(sourcePath) {\n    try {\n      let buffer;\n      const wavefile = require(\"wavefile\");\n      const { FFMPEGWrapper } = require(\"./ffmpeg\");\n      const ffmpeg = new FFMPEGWrapper();\n      const outFolder = path.resolve(__dirname, `../../storage/tmp`);\n      if (!fs.existsSync(outFolder))\n        fs.mkdirSync(outFolder, { recursive: true });\n\n      const outputFile = path.resolve(outFolder, `${v4()}.wav`);\n      const success = await ffmpeg.convertAudioToWav(sourcePath, outputFile);\n      if (!success)","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/collector/utils/WhisperProviders/localWhisper.js#L39-L75","documentation":"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.","triggerScenarios":"Long audio whose upsampled footprint would exceed the budget: upsampledSamples = duration * 16000 > 230_400_000.","commonSituations":"Very long recordings; audio near the 4 h ceiling where the upsample projection tips over the limit.","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."],"exampleFix":"// before\nconst MAX_SAMPLES = 230_400_000;\nif (upsampledSamples > MAX_SAMPLES) throw new Error(\"...maximum allowed length.\");\n\n// after — report the projection\nif (upsampledSamples > MAX_SAMPLES)\n  throw new Error(`Projected ${upsampledSamples} samples exceeds ${MAX_SAMPLES}.`);","handlingStrategy":"validation","validationCode":"function projectedSamples(wav, target = 16000) {\n  return (wav.data.samples / wav.fmt.sampleRate) * target;\n}\n// if (projectedSamples(wav) > 230_400_000) chunk the input;","typeGuard":null,"tryCatchPattern":"try { this.#validateAudioFile(wavFile); }\ncatch (e) {\n  if (e.message.includes(\"maximum allowed length\")) { /* split input */ }\n  throw e;\n}","preventionTips":["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."],"tags":["audio","whisper","validation","memory","limits"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}