Skip to content
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 MP3 resampling when a dataset's audio files have different sampling rates #3665

Merged
merged 4 commits into from
Feb 2, 2022

Conversation

lhoestq
Copy link
Member

@lhoestq lhoestq commented Feb 2, 2022

The resampler needs to be updated if the orig_freq doesn't match the audio file sampling rate

Fix #3662

@lhoestq lhoestq requested a review from anton-l February 2, 2022 10:36
Copy link
Member

@anton-l anton-l left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the fix!

@@ -174,7 +174,7 @@ def _decode_mp3(self, path_or_file):

array, sampling_rate = torchaudio.load(path_or_file, format="mp3")
if self.sampling_rate and self.sampling_rate != sampling_rate:
if not hasattr(self, "_resampler"):
if not hasattr(self, "_resampler") or self._resampler.orig_freq != sampling_rate:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice workaround, this should minimize the number of required _resampler replacements 👍

@lhoestq lhoestq merged commit 9ee6d90 into master Feb 2, 2022
@lhoestq lhoestq deleted the fix-mp3-resampling branch February 2, 2022 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Audio] MP3 resampling is incorrect when dataset's audio files have different sampling rates
2 participants