Librosa mp3 import

8,424 views
Skip to first unread message

Adil Attarhlibi

unread,
Sep 8, 2015, 2:19:29 PM9/8/15
to librosa
Hello !

I am trying to use different functions of the Librosa module for Python.

Unfortunately, I always have to convert my audio files from mp3 to wav. Actually, strangely the librosa.load function does not support mp3 format.
y,r=librosa.load("C:\\Users\\Adil\\Downloads\\01 Be-Bop-A-Lula.mp3"

I get the following error message :
 raise NoBackendError()

NoBackendError

Do you know how I can solve this issue ?

Thank you very much !

Brian McFee

unread,
Sep 8, 2015, 2:30:39 PM9/8/15
to librosa
Librosa does not handle audio coding directly.  It relies on the audioread package to interface between different decoding libraries (pymad, gstreamer, ffmpeg, etc).

The exception that you're getting is coming from audioread because it can't find a back-end to handle mp3 encoding.  You should verify that one of the mp3-supporting back-ends is properly installed.

As a side note, it looks like you're running on windows, which (to me at least) is uncharted territory with librosa.  I'd be very interested in any quirks you happen to encounter!

I hope this helps.  If you do encounter anything unexpected in getting things running, it would be great if you could report back and document the issues in this thread for future reference.

Adil Attarhlibi

unread,
Sep 10, 2015, 1:46:40 AM9/10/15
to librosa
I solved the issue. This was quite easy :
1. Install ffmpeg and set "ffmpeg" as a environment variable
2. Run the following command in Pyton 2.7 :
from subprocess import call
r=call('ffmpeg -i "test.mp3" -acodec pcm_u8 -ar 22050 "test.wav"',shell=True)
3. Then you can easily load the output fiel (wav) by librosa module:
import librosa
y, sr = librosa.load("test.wav")

However, I get a strange warning when importing librosa :
C:\Anaconda\lib\site-packages\librosa\core\audio.py:33: UserWarning: Could not import scikits.samplerate. Falling back to scipy.signal
  warnings.warn('Could not import scikits.samplerate. '

I don't know how to block the display of this warning.


Cheers

Brian McFee

unread,
Sep 10, 2015, 9:07:30 AM9/10/15
to librosa
Installing ffmpeg (step 1) should be sufficient; audioread should make step 2 unnecessary.  If audioread can't automatically detect ffmpeg as a backend, then that's a problem on their end.


On Thursday, September 10, 2015 at 1:46:40 AM UTC-4, Adil Attarhlibi wrote:
I solved the issue. This was quite easy :
1. Install ffmpeg and set "ffmpeg" as a environment variable
2. Run the following command in Pyton 2.7 :
from subprocess import call
r=call('ffmpeg -i "test.mp3" -acodec pcm_u8 -ar 22050 "test.wav"',shell=True)
3. Then you can easily load the output fiel (wav) by librosa module:
import librosa
y, sr = librosa.load("test.wav")

However, I get a strange warning when importing librosa :
C:\Anaconda\lib\site-packages\librosa\core\audio.py:33: UserWarning: Could not import scikits.samplerate. Falling back to scipy.signal
  warnings.warn('Could not import scikits.samplerate. '

I don't know how to block the display of this warning.


Please refer to the python warnings documentation for suppressing warnings.

ryands...@gmail.com

unread,
Oct 3, 2017, 10:04:19 AM10/3/17
to librosa
how did you install ffmpeg?

vinayku...@gmail.com

unread,
Jul 11, 2018, 4:15:03 AM7/11/18
to librosa
[Ubuntu]: > sudo apt-get install ffmpeg

Niranjan Rana

unread,
Aug 2, 2019, 10:43:22 AM8/2/19
to librosa
Guys use google colab to run your scripts it works there fine.

**Constraints for size of payload u upload. 

John Davis

unread,
Aug 2, 2019, 11:09:03 AM8/2/19
to Niranjan Rana, librosa
It needs ffmpeg

--
You received this message because you are subscribed to the Google Groups "librosa" group.
To unsubscribe from this group and stop receiving emails from it, send an email to librosa+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/librosa/e8c5845e-59ea-44b7-b154-459f4e85ac2d%40googlegroups.com.
--
Rocking the roll like a natural man!
Reply all
Reply to author
Forward
0 new messages