Repository navigation
Reduce feature extraction memory on long recordings - #1730
Open
hellomiku831 wants to merge 1 commit into
Open
hellomiku831 wants to merge 1 commit into
hellomiku831 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.
With VAD off,
transcribe()extracts features for the whole recording before it starts decoding. The NumPy STFT ends up allocating a windowed frame array and a complex spectrum for the entire file. This is the allocation people ran into in #1234.This patch computes up to 4,096 frames at a time and writes each block into the final Mel array. Reflection padding still applies at the two ends of the recording, and the log-Mel floor still uses the maximum over the whole recording.
I compared peak process working set on Windows with NumPy 2.2.6. Each cell is a fresh Python process with one OpenBLAS thread, an 80-bin extractor, and a seeded mono float32 input at 16 kHz.
I also compared every feature against the original extractor on all five audio fixtures in
tests/data. The largest absolute difference was1.2e-7. On NumPy 1.26.4 the five-minute benchmark went from 302.8 to 122.6 MiB with identical features.The new test covers off-hop input lengths, an odd FFT size, and quiet audio followed by louder audio. It also checks that a long recording isn't sent to the FFT in one piece.