feat(mel): optimize incremental mel processing#24
Closed
Conversation
Refactors `JsPreprocessor.computeRawMel` to accept an optional `startFrame` parameter, allowing STFT computation to be skipped for cached prefixes. Updates `IncrementalMelProcessor.process` to utilize this optimization, avoiding recomputation of `safeFrames` and instead filling them from the cache. Also optimizes the "cache miss" path in `IncrementalMelProcessor.process` to avoid double computation (previously calling both `process` and `computeRawMel`). Results in ~2x speedup for full processing (cache miss) and significantly faster incremental updates (skipping proportional to overlap). Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Owner
Author
|
Handled in PR#34 (release branch). Closing superseded PR. |
Contributor
Understood. Acknowledging that this work is now obsolete and stopping work on this task. |
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.
This PR addresses the inefficient incremental mel processing in
src/mel.js.Changes:
JsPreprocessor.computeRawMel(audio, startFrame=0): AddedstartFrameparameter. The STFT loop now starts fromstartFrame. The outputrawMelarray is initialized with zeros, so frames beforestartFrameare zeroed.IncrementalMelProcessor.process(Incremental Path): CalculatessafeFrames(cached prefix length) and passes it tocomputeRawMel. This skips STFT computation for the prefix. The prefix is then filled fromthis._cachedRawMel.IncrementalMelProcessor.process(Full Path): Refactored to callcomputeRawMelonce, thennormalizeFeatures. Previously it calledthis.preprocessor.process(audio)(full computation + norm) ANDthis.preprocessor.computeRawMel(audio)(full computation), doing double work.Verification:
npm test(tests/mel.test.mjs). All tests passed.PR created automatically by Jules for task 2619755791687996283 started by @ysdede