Mintplex-Labs/anything-llm · error · Error

Failed to transcribe audio.

Error message

Failed to transcribe audio.

What it means

Thrown by System.transcribeAudio when POST /system/transcribe-audio returns non-2xx. The endpoint receives multipart/form-data with an audio blob and returns { text } on success. The handler reads json.error for the server-side reason and falls back to 'Failed to transcribe audio.' The .catch returns { text: null, error } — note it does not log to console, unlike sibling methods.

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 526360e320)

Solutions

  1. Validate the audioBlob has non-zero size and a supported MIME type before posting.
  2. Confirm the backend transcription provider (Whisper) is configured with a valid API key.
  3. Raise the reverse-proxy client_max_body_size if the upload is being truncated.
  4. Add a console.error in the .catch (currently missing) so failures are visible in DevTools.

Example fix

// before
transcribeAudio: async function (audioBlob, filename = "audio.webm") {
  const formData = new FormData();
  formData.append("audio", audioBlob, filename);
  return fetch(...);
}

// after — guard empty blob
if (!audioBlob || audioBlob.size === 0) {
  return { text: null, error: "Audio recording is empty." };
}
Defensive patterns

Strategy: validation

Validate before calling

// Reject empty or unsupported blobs before uploading.
function isValidAudioBlob(blob, allowed = ['audio/webm','audio/wav','audio/mp3','audio/ogg']) {
  return blob && blob.size > 0 && allowed.includes(blob.type);
}

Type guard

function isTranscriptionSuccess(x): x is { text: string; error: null } {
  return x && typeof x.text === 'string' && x.error === null;
}

Try / catch

if (!isValidAudioBlob(audioBlob)) {
  return { text: null, error: 'Audio recording is empty or unsupported.' };
}
const { text, error } = await System.transcribeAudio(audioBlob, filename);
if (error) showToast(error);

Prevention

When it happens

Trigger: Audio blob is empty or in an unsupported container (e.g. audio/webm when only audio/wav is accepted), the configured transcription provider (Whisper) is unreachable or has no API key, the audio exceeds the server's max upload size, or the session expired.

Common situations: Browser MediaRecorder produced an empty blob because the user never granted microphone permission or spoke; backend Whisper provider key not configured; nginx/Cloudflare body-size limit smaller than the audio payload; user on a browser that records in a codec the server cannot decode.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/27109e583793bd6a. Report an issue: GitHub.