Skip to content

fix(audio): prevent empty recordings from crashing transcription#891

Open
xAlcahest wants to merge 1 commit into
OpenWhispr:mainfrom
xAlcahest:fix/empty-webm-recording
Open

fix(audio): prevent empty recordings from crashing transcription#891
xAlcahest wants to merge 1 commit into
OpenWhispr:mainfrom
xAlcahest:fix/empty-webm-recording

Conversation

@xAlcahest
Copy link
Copy Markdown
Collaborator

Summary

OpenWhispr intermittently recorded empty ~110-byte WebM files (just the container header, no audio frames), which crashed FFmpeg with "End of file" before any backend saw the audio and showed the raw crash text to the user. It's a timing race, easiest to hit in tap mode firing short clips in quick succession: MediaRecorder.start() had no timeslice, so a fast tap on a cold mic stopped the recorder before the encoder flushed a single frame, and onstop handed that header-only blob straight to processAudio.

The fix starts the recorder with a 250ms timeslice and a lazy mic-driver warm-up to make empty captures rarer, then drops degenerate recordings in onstop before they reach the backend, routing them to the existing "No Audio Detected" toast. The size check reuses recordingGuard.js from #872, kept byte-identical so the branches don't conflict.

Fixes #871

Changes

  • src/helpers/audioManager.js: 250ms recording timeslice, ondataavailable skips zero-size chunks and tracks received audio, onstop drops header-only / no-frame recordings before transcription, plus a lazy warmupMicDriver()
  • src/hooks/useAudioRecording.js: trigger the warm-up on first dictation use instead of at app launch
  • src/helpers/recordingValidation.js: new pure evaluateFinishedRecording deciding whether a finished recording carries usable audio
  • test/helpers/recordingValidation.test.js: tests for the helper (empty, header-only, boundary, missing-arg cases)
  • src/helpers/recordingGuard.js + test/helpers/recordingGuard.test.js: size-only empty guard, copied byte-identical from Fix dictation hotkey double-trigger on KDE Wayland #872

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Audio capture intermittently produces empty (~110 byte) webm files — transcription fails with 'FFmpeg: End of file' before whisper-server runs

1 participant