Mintplex-Labs/anything-llm · error · Error
Audio conversion failed.
Error message
Audio conversion failed.
What it means
Thrown by convertAudioBufferToWav when the collector's convertAudioToWav call did not return {success:true, wavFilename}, and result.reason was also falsy so the generic message is used. This function writes the source audio to the hotdir, asks the collector (FFMPEG wrapper) to convert it to WAV, and reads the result back. The generic message means the collector returned neither a reason nor a usable filename.
Source
Thrown at server/utils/SpeechToText/helpers.js:26
* Convert an audio buffer to a 16kHz mono WAV buffer via the collector's
* FFMPEG wrapper. Use this when the downstream STT provider (e.g. Lemonade)
* runs a whisper.cpp backend that rejects webm/opus input.
* @param {Buffer} audioBuffer - Source audio buffer.
* @param {string} extension - Source file extension including the leading dot (e.g. ".webm").
* @returns {Promise<Buffer>} The converted WAV buffer.
*/
async function convertAudioBufferToWav(audioBuffer, extension) {
let wavPath = null;
const sourceFilename = `stt-${v4()}${extension}`;
const sourcePath = path.resolve(hotdirPath, sourceFilename);
if (!isWithin(hotdirPath, sourcePath))
throw new Error("Source path is outside the hotdir.");
try {
await fs.writeFile(sourcePath, audioBuffer);
const result = await new CollectorApi().convertAudioToWav(sourceFilename);
if (!result?.success || !result?.wavFilename)
throw new Error(result?.reason || "Audio conversion failed.");
wavPath = path.resolve(hotdirPath, result.wavFilename);
return await fs.readFile(wavPath);
} finally {
await fs.rm(sourcePath, { force: true }).catch(() => {});
if (wavPath) await fs.rm(wavPath, { force: true }).catch(() => {});
}
}
module.exports = { convertAudioBufferToWav };
View on GitHub (pinned to 526360e320)
Solutions
- Check that the collector service is running and healthy (it is a separate process/container from the server).
- Verify FFMPEG is installed in the collector container (ffmpeg -version).
- Inspect collector logs for the actual conversion error, since result.reason is empty here.
- Ensure the extension argument includes the leading dot (e.g. '.webm') and the audioBuffer is non-empty.
- Confirm the hotdir path is writable and the source file was actually written.
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-check the collector is reachable before attempting conversion.
const healthy = await fetch(`${process.env.COLLECTOR_ENDPOINT || "http://collector"}/api/system-health`)
.then((r) => r.ok)
.catch(() => false);
if (!healthy) throw new Error("Collector service is unreachable; audio conversion will fail."); Try / catch
try {
return await convertAudioBufferToWav(audioBuffer, extension);
} catch (e) {
logger.error("WAV conversion failed:", e.message);
throw new Error("Could not convert audio for transcription. Is the collector + FFMPEG available?");
} Prevention
- Keep the collector container healthy and FFMPEG installed in its image.
- Pass the extension with a leading dot and ensure the buffer is non-empty.
- Log collector-side conversion errors so result.reason is populated for the next caller.
When it happens
Trigger: The collector microservice is not running or unreachable; FFMPEG is not installed in the collector container; the source audio codec is unsupported or the buffer is empty/corrupt; the collector returned {success:false} with no reason field.
Common situations: Collector container down or unhealthy; FFMPEG missing from the collector image; webm/opus input that FFMPEG cannot decode without additional libs; file system permissions on the hotdir; extension passed without a leading dot.
Related errors
- FFMPEG conversion failed
- FFMPEG candidate path not found.
- FFMPEG candidate path is not valid ffmpeg binary.
- FFMPEG binary not found.
- Input file ${inputPath} does not exist.
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/252851b5580bb735.
Report an issue: GitHub.