question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Default sample rate for librosa.core.load is not the native sample rate

See original GitHub issue

Currently, the default sample rate is 22050 Hz when loading an audio file. In order to use the native sample rate, sr must be set to None. I often forget to set this to None when I want the native sample rate, and I have noticed many students do the same.

Have others experienced confusion over this? Should this change in a later release so that the native sample rate is the default?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:31 (25 by maintainers)

github_iconTop GitHub Comments

3reactions
lostanlencommented, Feb 4, 2019

Hi @NumesSanguis. Thank you for the feedback.

soundfile.read doesn’t accept a samplerate keyword for changing the sample rate at load time (and my Google-fu skills couldn’t find how to do it with soundfile at all)

To be fair, librosa does not really change the sample rate “at load time”. It loads the whole file as a numpy array at its native sample rate, and then calls librosa.resample to perform resampling of that numpy array. Calling librosa.load with sr=None simply skips the second step.

So, if librosa.load were to be deprecated, the recommended way to perform its default behavior would be:

import soundfile as sf
original_y, original_sr = sf.read("sample.wav")
y = librosa.resample(original_y, original_sr, 22050)
2reactions
lostanlencommented, Feb 26, 2018

-1 to loadn

loadn strikes me as akin to idioms like kill -9, where you have to append something to the command so that it ends up doing what its name implies.

Read more comments on GitHub >

github_iconTop Results From Across the Web

librosa.load — librosa 0.10.0.dev0 documentation
Audio will be automatically resampled to the given rate (default sr=22050 ). To preserve the native sampling rate of the file, use sr=None...
Read more >
Sampling rate issue with Librosa - python - Stack Overflow
If you want to use the original sample rate, you have to explicitly set the the target sample rate to None: sr=None ....
Read more >
librosa.core.load — librosa 0.6.0 documentation
Load an audio file as a floating point time series. Audio will be automatically resampled to the given rate (default sr=22050). To preserve...
Read more >
Python Audio
Per default, librosa.load resamples the audio to 22050 Hz. Setting sr=None keeps the native sampling rate. The loaded audio is converted to a...
Read more >
Librosa: A Python Audio Libary. by - Medium
The default sampling rate used by Librosa is 22050, but you can pass in almost any sampling rate you like. Some common sampling...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found