Mintplex-Labs/anything-llm · error · Error
Failed to transcribe audio.
Error message
Failed to transcribe audio.
What it means
Thrown by the Telegram voice-transcription path when collector.parseDocument(filename) returns no usable result (result.success falsy or no documents). The audio buffer was already written to the collector hotdir and parsed; failure here means transcription itself failed or returned empty. The thrown message uses result.reason if provided, else the generic string.
Source
Thrown at server/utils/telegramBot/utils/media.js:61
* @param {string} [mimeType] - The MIME type of the audio (e.g., "audio/ogg")
* @returns {Promise<string>}
*/
async function transcribeAudio(audioBuffer, mimeType = "audio/ogg") {
const fs = require("fs");
const path = require("path");
const { CollectorApi } = require("../../collectorApi");
const { hotdirPath } = require("../../files");
if (!fs.existsSync(hotdirPath)) fs.mkdirSync(hotdirPath, { recursive: true });
const ext = getExtensionFromMime(mimeType);
const filename = `telegram-voice-${Date.now()}${ext}`;
fs.writeFileSync(path.join(hotdirPath, filename), audioBuffer);
const collector = new CollectorApi();
const result = await collector.parseDocument(filename);
if (!result?.success || !result.documents?.length) {
throw new Error(result?.reason || "Failed to transcribe audio.");
}
return result.documents[0].pageContent;
}
/**
* Parse a document buffer and extract its text content.
* Writes the document to the collector hotdir and runs it through
* the collector's parse pipeline.
* @param {Buffer} documentBuffer
* @param {string} originalFilename - The original filename with extension
* @returns {Promise<{text: string, filename: string}>}
*/
async function documentToText(documentBuffer, originalFilename) {
const fs = require("fs");
const path = require("path");
const { CollectorApi } = require("../../collectorApi");
const { hotdirPath } = require("../../files");
View on GitHub (pinned to 526360e320)
Solutions
- Check the collector logs for the underlying transcription error (often a model/API failure).
- Verify the transcription backend config (API key, model name, endpoint) in collector settings.
- Ensure ffmpeg/decoding deps are present in the collector image for the incoming codec.
- Reply to the user asking them to resend as a common format (.mp3, .ogg) if the codec is exotic.
Example fix
// before const text = (await collector.parseDocument(filename)).documents[0].pageContent; // after const result = await collector.parseDocument(filename); if (!result?.success || !result.documents?.length) throw new Error(result?.reason || 'Failed to transcribe audio.'); const text = result.documents[0].pageContent;
Defensive patterns
Strategy: try-catch
Validate before calling
const result = await collector.parseDocument(filename); if (!result?.success || !result.documents?.length) throw new Error(result?.reason || 'Failed to transcribe audio.');
Try / catch
try {
const text = await transcribeTelegramAudio(bot, fileId, mimeType);
} catch (e) {
if (e.message === 'Failed to transcribe audio.')
return ctx.reply('Transcription failed; please resend the voice message.');
throw e;
} Prevention
- Verify the transcription backend (API key, model) in collector settings.
- Ensure ffmpeg/codec deps are present for the incoming audio format.
- Log collector result.reason to diagnose specific failures.
When it happens
Trigger: A voice message in an unsupported audio codec; the collector's transcription backend (e.g. whisper) failing or misconfigured; an empty/corrupt audio buffer; the collector returning success=false with a reason.
Common situations: Whisper API key missing or invalid; collector container out of memory during transcription; audio file truncated during Telegram transfer; unsupported .oga variant the transcoder cannot decode.
Related errors
- Audio conversion failed.
- Document processing is unavailable. The collector service is
- Failed to parse document: ${originalFilename}
- Failed to sync YouTube video transcript. ${reason}
- No base URL was set.
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/75db60b431d9e7fb.
Report an issue: GitHub.