feat: save the audio behind an ONNX decode that returns nothing - #258
Merged
jatinkrmalik merged 2 commits intoSep 5, 2026
Merged
Conversation
An empty decode is the one failure with nothing to debug: no error, no text, and the audio is gone the moment the buffer is released. The bug in VocaHQ#256 took two wrong fixes before a dumped recording showed what was actually happening — the decode turned out to be so sensitive to its input that scaling the same samples by 1.001 changed the result, which no synthetic clip reproduced and no log line could have revealed. Write the samples to a WAV next to the logs so the failure can be replayed through --transcribe-file. Off unless asked for, since it puts recorded speech on disk: defaults write com.vocamac.app vocamac.debug.saveFailedAudio -bool true Keeps the newest 20 recordings so it cannot fill the disk, and only fires for audio that actually reached the decoder — digital silence is skipped before inference and is not a failure.
✅ Deploy Preview for voca-mac canceled.
|
|
| Filename | Overview |
|---|---|
| Sources/VocaMac/Services/FailedAudioDump.swift | Adds opt-in WAV persistence, collision-resistant filenames, logging, and retention pruning for failed decoding audio. |
| Sources/VocaMac/Services/SherpaService.swift | Saves decoder input when ONNX inference receives audio but returns an empty transcription. |
| Tests/VocaMacTests/FailedAudioDumpTests.swift | Adds coverage for WAV container fields, sample conversion, and the disabled-by-default preference. |
Reviews (2): Last reviewed commit: "Avoid colliding failed-audio dump filena..." | Re-trigger Greptile
Include a short UUID token so two empty ONNX dumps in the same second keep both WAV files. Sanitize model path characters too.
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.
Follow-up to #256 / #257, split out as its own change.
Why
An empty decode is the one failure with nothing to debug. There is no error, no text, and the audio is gone the moment the buffer is released — all that survives is a log line saying it produced nothing.
That cost two wrong fixes on #256. The first assumed speech starting in sample zero was the trigger; it was a trigger, but recordings kept being dropped. 174 generated clips and 12 with synthetic room-noise floors could not reproduce what a real microphone hit every few minutes.
Dumping one real failing recording settled it in minutes: the same samples scaled by 1.001 decoded to the full sentence, and by 0.999 to nothing. No synthetic clip would ever have shown that, and no log line could have.
What
When a decode returns nothing for audio that actually reached the decoder, write those samples to a WAV next to the logs, so the failure can be replayed through
--transcribe-fileand characterized offline.defaults write com.vocamac.app vocamac.debug.saveFailedAudio -bool trueswift test: 478 tests, 0 failures.Note
Filed separately from #257 rather than bundled with it — #257 is the fix, this is the instrument that found it. Reviewers who would rather not ship a debug dump can drop this one without touching the fix.