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.

Bug: Error when reading file with librosa, audioread reports `float division by zero` error

See original GitHub issue

Hello!

I was using the following piece of code,

audio, sample_rate = librosa.load(file_name, res_type='kaiser_fast')

But I was thrown the following error,

--> 103     audio, sample_rate = librosa.load(file_name, res_type='kaiser_fast')
    104     mfccs = librosa.feature.mfcc(y=audio, sr=sample_rate, n_mfcc=40)
    105     mfccs_processed = np.mean(mfccs.T,axis=0)

/opt/conda/lib/python3.7/site-packages/librosa/core/audio.py in load(path, sr, mono, offset, duration, dtype, res_type)
    170 
    171     if sr is not None:
--> 172         y = resample(y, sr_native, sr, res_type=res_type)
    173 
    174     else:

/opt/conda/lib/python3.7/site-packages/librosa/core/audio.py in resample(y, orig_sr, target_sr, res_type, fix, scale, **kwargs)
    551         return y
    552 
--> 553     ratio = float(target_sr) / orig_sr
    554 
    555     n_samples = int(np.ceil(y.shape[-1] * ratio))

ZeroDivisionError: float division by zero

I was trying to load a .mp3 using librosa, while using audioread as a backend. I am not sure why the error is ocuring, but I’ll use a try - catch block to avoid it. A similar issue is here, https://github.com/librosa/librosa/issues/765, but the solution to the problem by the author has not been stated.

Help would be appreciated. Thank you!

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
sampsyocommented, Aug 26, 2020

Hi! It looks like this error happens in librosa code, not in audioread code. So I’m not sure we can do anything about it… do you have more information that indicates that something is wrong in audioread itself?

0reactions
Rubix982commented, Nov 19, 2020

@Stapelueberflieger try out ps aux to see where the hardware consumption is going towards. Maybe you might need a lighter version for the device you have.

Read more comments on GitHub >

github_iconTop Results From Across the Web

'rasampy' output ZeroDivisionError - Google Groups
I use raspberry pi zero. Installing librosa on raspberry pi was successful. However, when resampling by the program, the following error was output....
Read more >
Troubleshooting — librosa 0.10.0.dev0 documentation
For bug reports and other, more technical issues, consult the github issues. Here are a few of the most common problems that users...
Read more >
ZeroDivisionError: float division by zero even though I have a ...
As the error says I thought this was because python was trying to do a integer division & rounding mcs to 0 but...
Read more >
Changelog — librosa 0.6.0 documentation
v0.6.0¶. 2018-02-17. Bug fixes. #663 fixed alignment errors in feature.delta. Brian McFee; #646 effects.trim now correctly handles all-zeros signals.
Read more >
Python Audio
When PySoundFile fails to read the audio file (e.g., for MP3), a warning is issued, and librosa.load falls back to another library called...
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