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

OPUS files and ground truth for sampling rate #157

Open
hagenw opened this issue Dec 17, 2024 · 1 comment · May be fixed by #158
Open

OPUS files and ground truth for sampling rate #157

hagenw opened this issue Dec 17, 2024 · 1 comment · May be fixed by #158
Labels
bug Something isn't working

Comments

@hagenw
Copy link
Member

hagenw commented Dec 17, 2024

The GigaSpeech dataset contains audio in opus files stored at 16,000 Hz.

I attached the file POD0000002525.opus to this issue.

>>> import audiofile
>>> file = "POD0000002525.opus"
>>> audiofile.sampling_rate(file)
16000
>>> audiofile.duration(file, sloppy=True)
536.144

But when reading the file in the usual way, the sampling rate no longer matches:

>>> signal, sampling_rate = audiofile.read(file)
>>> signal.shape
(25734790,)
>>> sampling_rate
48000

This also affects audiofile.samples() and audiofile.duration() as both uses audiofile.convert_to_wav(), which relies on audiofile.read() to get the ground truth for sampling rate:

>>> audiofile.samples(file)
25734790
>>> audiofile.duration(file)
1608.424375

This could be fixed by relying on audiofile.sampling_rate() inside audiofile.convert_to_wav(), but maybe we should also check, why the opus file behaves like this.

POD0000002525.zip

@hagenw hagenw added the bug Something isn't working label Dec 17, 2024
@hagenw hagenw linked a pull request Dec 17, 2024 that will close this issue
@hagenw
Copy link
Member Author

hagenw commented Dec 17, 2024

ffmpeg always returns opus files wit a sampling rate of 48000 Hz, if not otherwise specified. This is known and marked as not to be fixed, see https://trac.ffmpeg.org/ticket/5240. Which means in order to fix it we need to provide ffmpeg with the desired sampling rate when converting an opus file to wav.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant