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

Not loading mp3 files. #1075

Closed
nikhilkharade opened this issue Feb 21, 2020 · 1 comment
Closed

Not loading mp3 files. #1075

nikhilkharade opened this issue Feb 21, 2020 · 1 comment

Comments

@nikhilkharade
Copy link

nikhilkharade commented Feb 21, 2020

the load function is not loading a mp3 file

The code :
import os
import librosa

path = 'D:/fma_small/000/000002.mp3'

path = os.fspath(path)

y, sr = librosa.load(path, duration=10)

ps = librosa.feature.melspectrogram(y=y, sr=sr, n_mels=128)

ps.shape

Expected Results

Just the shape i.e. (128, 431)

Actual Results


RuntimeError Traceback (most recent call last)
c:\python37\lib\site-packages\librosa\core\audio.py in load(path, sr, mono, offset, duration, dtype, res_type)
128 try:
--> 129 with sf.SoundFile(path) as sf_desc:
130 sr_native = sf_desc.samplerate

c:\python37\lib\site-packages\soundfile.py in init(self, file, mode, samplerate, channels, subtype, endian, format, closefd)
628 format, subtype, endian)
--> 629 self._file = self._open(file, mode_int, closefd)
630 if set(mode).issuperset('r+') and self.seekable():

c:\python37\lib\site-packages\soundfile.py in _open(self, file, mode_int, closefd)
1183 _error_check(_snd.sf_error(file_ptr),
-> 1184 "Error opening {0!r}: ".format(self.name))
1185 if mode_int == _snd.SFM_WRITE:

c:\python37\lib\site-packages\soundfile.py in _error_check(err, prefix)
1356 err_str = _snd.sf_error_number(err)
-> 1357 raise RuntimeError(prefix + _ffi.string(err_str).decode('utf-8', 'replace'))
1358

RuntimeError: Error opening 'D:/fma_small/000/000002.mp3': File contains data in an unknown format.

During handling of the above exception, another exception occurred:

NoBackendError Traceback (most recent call last)
in
----> 1 y, sr = librosa.load(path, duration=10)
2 ps = librosa.feature.melspectrogram(y=y, sr=sr, n_mels=128)
3 ps.shape

c:\python37\lib\site-packages\librosa\core\audio.py in load(path, sr, mono, offset, duration, dtype, res_type)
145 if sys.version_info >= (3, 4):
146 import pathlib
--> 147
148 # check if a Path object is passed by the user
149 if isinstance(path, pathlib.PurePath):

c:\python37\lib\site-packages\librosa\core\audio.py in __audioread_load(path, offset, duration, dtype)
169
170 if sr is not None:
--> 171 y = resample(y, sr_native, sr, res_type=res_type)
172
173 else:

c:\python37\lib\site-packages\audioread_init_.py in audio_open(path, backends)
114
115 # All backends failed!
--> 116 raise NoBackendError()

NoBackendError:

Versions

@lostanlen
Copy link
Contributor

Hello, please read this part of the documentation on MP3 decoding:
https://github.com/librosa/librosa#audioread-and-mp3-support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants