Repository navigation
Conversation
_streaming_melspectrogram copied the whole 10 s raw audio deque into a list on every call, then used only the newest n_samples + 480 samples. Read those from the end of the deque instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
AudioFeatures._streaming_melspectrogramruns on every streamed chunk. It doeslist(self.raw_data_buffer)[-n_samples-160*3:], which turns the whole raw audio deque (maxlen=sr*10, 160,000 samples) into a list just to keep the newestn_samples + 480. This change reads those samples from the end of the deque instead, so a call costs time in proportion to the chunk, not the 10 s buffer.Nothing else changes: the buffer, its size and
_buffer_raw_dataare untouched.Same output. I compared it against the current code with
hey_jarvis_v0.1andalexa_v0.1on 60 s of speech and noise, seeding numpy before each model, sinceAudioFeaturesfills its feature buffer with random audio:melspectrogram_bufferandfeature_bufferwere identical for 80 ms chunks, and for mixed chunk sizes from 333 samples to 1 s;reset();Speex with uneven chunk sizes differs from run to run even on the current code, so that case can't be compared.
Faster. Median
predict()time per 80 ms chunk, speex on, both models, pinned to one core in a Linux aarch64 container on Apple silicon:On a Raspberry Pi CM5 the current code measured 7.9 ms per chunk with a single wake word model. I haven't timed this change there yet.
tests/test_models.pypasses (16 tests), and flake8 is clean at the project's 140-character limit.🤖 Generated with Claude Code