fix(audio): prevent empty recordings from crashing transcription#891
Open
xAlcahest wants to merge 1 commit into
Open
fix(audio): prevent empty recordings from crashing transcription#891xAlcahest wants to merge 1 commit into
xAlcahest wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, andonstophanded that header-only blob straight toprocessAudio.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
onstopbefore they reach the backend, routing them to the existing "No Audio Detected" toast. The size check reusesrecordingGuard.jsfrom #872, kept byte-identical so the branches don't conflict.Fixes #871
Changes
ondataavailableskips zero-size chunks and tracks received audio,onstopdrops header-only / no-frame recordings before transcription, plus a lazywarmupMicDriver()evaluateFinishedRecordingdeciding whether a finished recording carries usable audio