-
-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix sample rate issues #153
Conversation
# Dynamic resampling if the audio source isn't compatible | ||
if sample_rate != self.source.sample_rate: | ||
msg = f"Audio source has sample rate {self.source.sample_rate}, " \ | ||
f"but pipeline's is {sample_rate}. Will resample." | ||
logging.warning(msg) | ||
self.stream = self.stream.pipe( | ||
ops.map(blocks.Resample(self.source.sample_rate, sample_rate)) | ||
ops.map(blocks.Resample(self.source.sample_rate, sample_rate, self.pipeline.config.device)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resample before rearrange_audio_stream
so the same audio is not resampled multiple times.
Because of how the first 5s buffer is filled at the beginning, this actually means that Resample
will be called more times, but (unless it's running on GPU) each call should also be faster because the size of the chunk is reduced by 10 (80k vs 8k samples)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's track this for a future PR, see #180
c878998
to
9fd258f
Compare
* Add automatic sample rate detection in MicrophoneAudioSource. Fix resampling crash. * Replace block_size by block_duration in audio source constructors
This PR addresses issue #152.
Changelog
MicrophoneAudioSource
now detects supported sample rates and chooses the lowest possible one (higher than 16khz)MicrophoneAudioSource
no longer receives asample_rate
argumentblock_size
argument toblock_duration
in all audio sourcesStreamingInference
when resampling audio to pipeline's sample rateResample
can now run on GPU by passing adevice
argument