Mintplex-Labs/anything-llm · error · Error

json?.error || "Failed to transcribe audio."

Error message

json?.error || "Failed to transcribe audio."

What it means

Thrown by transcribeAudio in the AnythingLLM frontend when POST /api/system/transcribe-audio (multipart audio blob) fails, preferring the server's json.error over the fallback string. The server routes transcription to the configured provider — OpenAI's API or a local Whisper model — so the error usually names the provider-level failure.

Source

Thrown at frontend/src/models/system.js:926

  /**
   * Send a recorded audio blob to the configured server-side STT provider
   * for transcription. Returns the transcribed text or an error string.
   * @param {Blob} audioBlob - Recorded audio (e.g., audio/webm) to transcribe.
   * @param {string} [filename] - Filename hint for the upload.
   * @returns {Promise<{text: string|null, error: string|null}>}
   */
  transcribeAudio: async function (audioBlob, filename = "audio.webm") {
    const formData = new FormData();
    formData.append("audio", audioBlob, filename);
    return fetch(`${API_BASE}/system/transcribe-audio`, {
      method: "POST",
      headers: baseHeaders(),
      body: formData,
    })
      .then(async (res) => {
        const json = await res.json();
        if (!res.ok)
          throw new Error(json?.error || "Failed to transcribe audio.");
        return { text: json?.text ?? "", error: null };
      })
      .catch((e) => ({ text: null, error: e.message }));
  },

  experimentalFeatures: {
    liveSync: LiveDocumentSync,
    agentPlugins: AgentPlugins,
  },
  promptVariables: SystemPromptVariable,
};

export default System;

View on GitHub (pinned to 20f6d3546c)

Solutions

  1. Read the returned `error` — it names the provider problem ('model not found', 'Incorrect API key').
  2. For local transcription: download the Whisper model in system settings before speaking.
  3. For the OpenAI provider: set a valid API key.
  4. Verify the recorded blob has a non-trivial size/duration before uploading.
Defensive patterns

Strategy: validation

Validate before calling

// run before System.transcribeAudio
if (!(audioBlob instanceof Blob) || audioBlob.size < 1024) {
  throw new Error('Recording is empty — check microphone permission');
}

Type guard

/** @param {any} b @returns {b is Blob} */
function isRecordableAudio(b) {
  return b instanceof Blob && b.size > 0;
}

Try / catch

const { text, error } = await System.transcribeAudio(audioBlob, filename);
if (error) {
  // error names the provider problem: missing model, bad API key, unsupported audio
  showTranscriptionError(error);
  return;
}

Prevention

When it happens

Trigger: No transcription provider configured (no OpenAI key and the local Whisper model never downloaded); the local whisper model missing or corrupt; an empty/tiny audio blob (e.g. MediaRecorder produced no data because the mic was blocked); provider API errors such as an invalid key or rate limit.

Common situations: Fresh self-hosted install without a whisper model pulled; microphone permission denied so the recording is empty; expired OpenAI key; recording shorter than the model can process.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@20f6d3546c (2026-08-18). Data as JSON: /api/errors/e711e9309b8a90fe. Report an issue: GitHub.