{"record":{"id":"e711e9309b8a90fe","repo":"Mintplex-Labs/anything-llm","slug":"json-error-failed-to-transcribe-audio","errorCode":null,"errorMessage":"json?.error || \"Failed to transcribe audio.\"","messagePattern":"json\\?\\.error \\|\\| \"Failed to transcribe audio\\.\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"frontend/src/models/system.js","lineNumber":926,"sourceCode":"  /**\n   * Send a recorded audio blob to the configured server-side STT provider\n   * for transcription. Returns the transcribed text or an error string.\n   * @param {Blob} audioBlob - Recorded audio (e.g., audio/webm) to transcribe.\n   * @param {string} [filename] - Filename hint for the upload.\n   * @returns {Promise<{text: string|null, error: string|null}>}\n   */\n  transcribeAudio: async function (audioBlob, filename = \"audio.webm\") {\n    const formData = new FormData();\n    formData.append(\"audio\", audioBlob, filename);\n    return fetch(`${API_BASE}/system/transcribe-audio`, {\n      method: \"POST\",\n      headers: baseHeaders(),\n      body: formData,\n    })\n      .then(async (res) => {\n        const json = await res.json();\n        if (!res.ok)\n          throw new Error(json?.error || \"Failed to transcribe audio.\");\n        return { text: json?.text ?? \"\", error: null };\n      })\n      .catch((e) => ({ text: null, error: e.message }));\n  },\n\n  experimentalFeatures: {\n    liveSync: LiveDocumentSync,\n    agentPlugins: AgentPlugins,\n  },\n  promptVariables: SystemPromptVariable,\n};\n\nexport default System;\n","sourceCodeStart":908,"sourceCodeEnd":940,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/20f6d3546c1938bfea1ad304f58a592dddcc5948/frontend/src/models/system.js#L908-L940","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the returned `error` — it names the provider problem ('model not found', 'Incorrect API key').","For local transcription: download the Whisper model in system settings before speaking.","For the OpenAI provider: set a valid API key.","Verify the recorded blob has a non-trivial size/duration before uploading."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// run before System.transcribeAudio\nif (!(audioBlob instanceof Blob) || audioBlob.size < 1024) {\n  throw new Error('Recording is empty — check microphone permission');\n}","typeGuard":"/** @param {any} b @returns {b is Blob} */\nfunction isRecordableAudio(b) {\n  return b instanceof Blob && b.size > 0;\n}","tryCatchPattern":"const { text, error } = await System.transcribeAudio(audioBlob, filename);\nif (error) {\n  // error names the provider problem: missing model, bad API key, unsupported audio\n  showTranscriptionError(error);\n  return;\n}","preventionTips":["Download the local Whisper model (or configure an OpenAI key) before enabling voice input.","Verify microphone permission and a non-trivial blob size before uploading.","Surface provider-specific errors to the user — the fallback string hides the cause."],"tags":["anythingllm","audio-transcription","whisper","file-upload"],"backgroundTag":"audio-transcription-failed","analyzedSha":"20f6d3546c1938bfea1ad304f58a592dddcc5948","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}