Skip to content

feat: save the audio behind an ONNX decode that returns nothing - #258

Merged
jatinkrmalik merged 2 commits into
VocaHQ:mainfrom
Mr-Sunglasses:feat/dump-failed-onnx-audio
Sep 5, 2026
Merged

feat: save the audio behind an ONNX decode that returns nothing#258
jatinkrmalik merged 2 commits into
VocaHQ:mainfrom
Mr-Sunglasses:feat/dump-failed-onnx-audio

Conversation

@Mr-Sunglasses

Copy link
Copy Markdown
Member

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-file and characterized offline.

  • Off unless asked for — 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.
  • Only fires for audio that reached the decoder. Digital silence is skipped before inference and is not a failure, so it is not dumped.
  • Writes a plain 16-bit mono WAV with a hand-rolled 44-byte header — no AVFoundation dependency, and the header is unit-tested field by field.

swift 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.

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.
@netlify

netlify Bot commented Sep 5, 2026

Copy link
Copy Markdown

Deploy Preview for voca-mac canceled.

Name Link
🔨 Latest commit cc61b56
🔍 Latest deploy log https://app.netlify.com/projects/voca-mac/deploys/6a9bcb24ac51050008ed4d39

@github-actions github-actions Bot added app bug Something isn't working ci and removed ci labels Sep 5, 2026
@greptile-apps

greptile-apps Bot commented Sep 5, 2026

Copy link
Copy Markdown

Greptile Summary

Adds opt-in diagnostic persistence for audio associated with empty ONNX decoding results.

  • Encodes failed audio as 16-bit mono WAV files alongside application logs.
  • Adds unique filename tokens and retains only the newest 20 recordings.
  • Adds coverage for WAV encoding and the disabled-by-default preference.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

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

Comment thread Sources/VocaMac/Services/FailedAudioDump.swift Outdated
Include a short UUID token so two empty ONNX dumps in the same
second keep both WAV files. Sanitize model path characters too.
@jatinkrmalik
jatinkrmalik merged commit c71f20d into VocaHQ:main Sep 5, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants