{"record":{"id":"4da0a54faaa509a4","repo":"iOfficeAI/AionUi","slug":"stt-file-too-large","errorCode":"STT_FILE_TOO_LARGE","errorMessage":"STT_FILE_TOO_LARGE","messagePattern":"STT_FILE_TOO_LARGE","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/desktop/src/renderer/services/SpeechToTextService.ts","lineNumber":40,"sourceCode":"      return 'mp3';\n    case 'audio/ogg':\n    case 'audio/ogg;codecs=opus':\n      return 'ogg';\n    case 'audio/wav':\n    case 'audio/wave':\n      return 'wav';\n    default:\n      return 'webm';\n  }\n};\n\nconst createAudioFileName = (mimeType: string) => {\n  return `speech-input.${getAudioExtension(mimeType)}`;\n};\n\nconst ensureAudioSize = (blob: Blob) => {\n  if (blob.size > MAX_AUDIO_FILE_SIZE_BYTES) {\n    throw new Error('STT_FILE_TOO_LARGE');\n  }\n};\n\nconst parseSuccessResponse = (response: XMLHttpRequest): SpeechToTextResult => {\n  const payload = JSON.parse(response.responseText) as {\n    data?: SpeechToTextResult;\n    msg?: string;\n    success: boolean;\n  };\n\n  if (!payload.success || !payload.data) {\n    throw new Error(payload.msg || 'STT_REQUEST_FAILED');\n  }\n\n  return payload.data;\n};\n\n// Surface the backend error code (STT_DISABLED, STT_OPENAI_NOT_CONFIGURED, ...)","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/iOfficeAI/AionUi/blob/711aa0550ee183ea495dc33e2c05c7943b70a60a/packages/desktop/src/renderer/services/SpeechToTextService.ts#L22-L58","documentation":"Before uploading a recorded blob for speech-to-text, `ensureAudioSize` enforces `MAX_AUDIO_FILE_SIZE_BYTES`. The error code `STT_FILE_TOO_LARGE` signals the client-side recording exceeds the upload cap, avoiding a doomed network request.","triggerScenarios":"Calling `transcribeAudioBlob` with a Blob whose `size` exceeds MAX_AUDIO_FILE_SIZE_BYTES — typically a long dictation recording, or a high-bitrate audio mimeType producing large payloads.","commonSituations":"Users recording very long voice messages; browsers producing large WAV/PCM blobs (uncompressed) versus compact webm/opus; the cap being lowered without adjusting UX to warn about recording length.","solutions":["Shorten the recording or stop recording earlier (enforce a max duration in the recorder UI)","Prefer compressed mime types (audio/webm;codecs=opus) over uncompressed WAV/PCM to shrink blob size","Check/raise MAX_AUDIO_FILE_SIZE_BYTES if the backend actually supports larger uploads","Show a live size/duration indicator and stop automatically near the cap"],"exampleFix":"// before\nconst ensureAudioSize = (blob: Blob) => {\n  if (blob.size > MAX_AUDIO_FILE_SIZE_BYTES) {\n    throw new Error('STT_FILE_TOO_LARGE');\n  }\n};\n\n// after (stop recording before exceeding the cap)\nif (recorder && elapsedBytesRef.current >= MAX_AUDIO_FILE_SIZE_BYTES) recorder.stop();","handlingStrategy":"validation","validationCode":"if (blob.size > MAX_AUDIO_FILE_SIZE_BYTES) { /* warn user, refuse upload */ }","typeGuard":"const isAudioSizeOk = (blob: Blob): boolean => blob.size <= MAX_AUDIO_FILE_SIZE_BYTES;","tryCatchPattern":"catch (e) { if (e.message === 'STT_FILE_TOO_LARGE') toast.warning(t('speech.fileTooLarge')); }","preventionTips":["Cap recording duration in the recorder UI","Prefer compressed codecs (opus/webm) over WAV"],"tags":["speech-to-text","audio","file-size","upload-limit"],"backgroundTag":"request-payload-too-large","analyzedSha":"711aa0550ee183ea495dc33e2c05c7943b70a60a","analyzedAt":"2026-08-28T07:56:06.558Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}