fix(audio): reset resampler state between recordings to prevent audio crosstalk#1344
Open
andrewleech wants to merge 1 commit into
Open
fix(audio): reset resampler state between recordings to prevent audio crosstalk#1344andrewleech wants to merge 1 commit into
andrewleech wants to merge 1 commit into
Conversation
Owner
|
Probably a good change, I will test it when I can and pull it in |
The FrameResampler was created once per audio session and reused across multiple recordings without clearing its internal buffers. The rubato FftFixedIn overlap buffers retained audio from the previous recording, causing the first ~30ms of each new recording to contain stale samples. This manifested as lost/corrupted words at the start of transcriptions and occasional stale text fragments (e.g. "ology.") from previous sessions leaking into new ones. Fix: add FrameResampler::reset() that clears in_buf, pending, and calls rubato's reset() to zero the FFT overlap buffers. Called on Cmd::Start alongside the existing processed_samples and VAD resets.
2bc524c to
d560930
Compare
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.
Before Submitting This PR
Please confirm you have done the following:
Human Written Description
The
FrameResampleris created once per audio session and reused across multiple recordings without clearing its internal buffers. The rubatoFftFixedInoverlap buffers retained audio from the previous recording, so the first ~30ms of each new recording contained stale samples from the prior one. This manifested as lost or corrupted words at the start of transcriptions and occasional stale text fragments (e.g. `ology.`) leaking into new sessions.Adding a
reset()that clearsin_buf,pending, and calls rubato's ownreset()to zero the FFT overlap buffers — invoked onCmd::Startalongside the existingprocessed_samplesand VAD resets — fixes it cleanly without touching the steady-state hot path.Related Issues/Discussions
Fixes #
Community Feedback
Not yet gathered. The bug surfaced from my own use rather than a reported issue, but it's a real correctness problem affecting any user who records back-to-back without restarting the app.
Testing
Screenshots/Videos (if applicable)
N/A — audio-pipeline correctness fix.
AI Assistance
If AI was used: