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.

error when loading the librosa example

See original GitHub issue

Description

When I tried to load the example audio of librosa following the example code provided, I encountered an error of division by 0.

Steps/Code to Reproduce

# I used the following code after importing librosa
filename = librosa.util.example_audio_file()
y, sr = librosa.load(filename)
y
# expected output: array([ -4.756e-06,  -6.020e-06, ...,  -1.040e-06,   0.000e+00], dtype=float32) 

but I got the following error:

---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
<ipython-input-58-51ccf84ebac8> in <module>()
----> 1 y, sr = librosa.load(filename)

/anaconda2/lib/python2.7/site-packages/librosa/core/audio.pyc in load(path, sr, mono, offset, duration, dtype, res_type)
    158 
    159         if sr is not None:
--> 160             y = resample(y, sr_native, sr, res_type=res_type)
    161 
    162         else:

/anaconda2/lib/python2.7/site-packages/librosa/core/audio.pyc in resample(y, orig_sr, target_sr, res_type, fix, scale, **kwargs)
    277         return y
    278 
--> 279     ratio = float(target_sr) / orig_sr
    280 
    281     n_samples = int(np.ceil(y.shape[-1] * ratio))

ZeroDivisionError: float division by zero

Expected Results

Actual Results

Versions

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
chanjeedcommented, Oct 25, 2019

@lvbaouu I am stuck with exact same issue with some of my mp3 files. Can you tell me how you fixed it?

2reactions
lvbaouucommented, Mar 19, 2019

yeah, it worked. sorry for the delayed response.

On Mon, Oct 1, 2018 at 8:22 PM Brian McFee notifications@github.com wrote:

Thanks for reporting this. I’ve never seen that before, but I’m pretty sure that it’s coming from an upstream dependency (audioread) incorrectly reporting the sample rate of the input file as 0, when it should be 44100. Why it’s doing that, I’m not sure, but it’s probably something going wrong in one of audioread’s codec backends (ffmpeg or gstreamer). I suggest that you take it up with the audioread developers.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/librosa/librosa/issues/765#issuecomment-426106243, or mute the thread https://github.com/notifications/unsubscribe-auth/ApvQEcJRJiOkLoEMAM7fNGSfqvBKQ48Yks5ugrHIgaJpZM4XDBmH .

Read more comments on GitHub >

github_iconTop Results From Across the Web

librosa.load: file not found error on loading a file - Stack Overflow
Two things: It looks like you are using Homebrew; avconv is not in your path. Assuming, you have never installed it, you should...
Read more >
Troubleshooting — librosa 0.10.0.dev0 documentation
If you're trying to run some example code, and encounter the following error message: AttributeError: module 'librosa' has no attribute 'display'.
Read more >
Librosa not loading mp3 files from dataset. - Reddit
I am working on genre classifying model. An issue I am encountering is librosa is not loading the mp3 file. I am getting...
Read more >
Python Audio
When reading audio, librosa.load first tries to use PySoundFile . This works for many formats, such as WAV, FLAC, and OGG. However, MP3...
Read more >
Jupyter Audio Basics - Music Information Retrieval
If you receive an error with librosa.load , you may need to install ffmpeg. Display the length of the audio array and sample...
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