---------------------------------------------------------------------------RuntimeError Traceback (most recent call last)
File c:\users\bahar\appdata\local\programs\python\python39\lib\site-packages\librosa\core\audio.py:155, in load(path, sr, mono, offset, duration, dtype, res_type)
153 else:
154 # Otherwise, create the soundfile object
--> 155 context = sf.SoundFile(path)
157 with context as sf_desc:
File c:\users\bahar\appdata\local\programs\python\python39\lib\site-packages\soundfile.py:629, in SoundFile.__init__(self, file, mode, samplerate, channels, subtype, endian, format, closefd)
627 self._info = _create_info_struct(file, mode, samplerate, channels,
628 format, subtype, endian)
--> 629 self._file = self._open(file, mode_int, closefd)
630 if set(mode).issuperset('r+') and self.seekable():
631 # Move write position to 0 (like in Python file objects)
File c:\users\bahar\appdata\local\programs\python\python39\lib\site-packages\soundfile.py:1183, in SoundFile._open(self, file, mode_int, closefd)
1182 raiseTypeError("Invalid file: {0!r}".format(self.name))
-> 1183 _error_check(_snd.sf_error(file_ptr),
1184 "Error opening {0!r}: ".format(self.name))
1185 if mode_int == _snd.SFM_WRITE:
1186 # Due to a bug in libsndfile version <= 1.0.25, frames != 0
1187 # when opening a named pipe in SFM_WRITE mode.
1188 # See http://github.com/erikd/libsndfile/issues/77.
File c:\users\bahar\appdata\local\programs\python\python39\lib\site-packages\soundfile.py:1357, in _error_check(err, prefix)
1356 err_str = _snd.sf_error_number(err)
-> 1357raiseRuntimeError(prefix + _ffi.string(err_str).decode('utf-8', 'replace'))
RuntimeError: Error opening 'C:\\Python\\Music\\Hiroshi Suzuki-Romance.mp3': File contains data in an unknown format.
During handling of the above exception, another exception occurred:
NoBackendError Traceback (most recent call last)
Input In [2], in <module>
1 audio_data = 'C:\\Python\\Music\\Hiroshi Suzuki-Romance.mp3'
----> 2 x , sr = librosa.load(audio_data)
3 print(type(x), type(sr))
File c:\users\bahar\appdata\local\programs\python\python39\lib\site-packages\librosa\util\decorators.py:88, in deprecate_positional_args.<locals>._inner_deprecate_positional_args.<locals>.inner_f(*args, **kwargs)
86 extra_args = len(args) - len(all_args)
87 if extra_args <= 0:
---> 88return f(*args, **kwargs)
90 # extra_args > 0
91 args_msg = [
92 "{}={}".format(name, arg)
93 for name, arg in zip(kwonly_args[:extra_args], args[-extra_args:])
94 ]
File c:\users\bahar\appdata\local\programs\python\python39\lib\site-packages\librosa\core\audio.py:174, in load(path, sr, mono, offset, duration, dtype, res_type)
172 if isinstance(path, (str, pathlib.PurePath)):
173 warnings.warn("PySoundFile failed. Trying audioread instead.", stacklevel=2)
--> 174 y, sr_native = __audioread_load(path, offset, duration, dtype)
175 else:
176 raise (exc)
File c:\users\bahar\appdata\local\programs\python\python39\lib\site-packages\librosa\core\audio.py:198, in __audioread_load(path, offset, duration, dtype)
192 """Load an audio buffer using audioread.
193
194 This loads one block at a time, and then concatenates the results.
195 """
197 y = []
--> 198with audioread.audio_open(path) as input_file:
199 sr_native = input_file.samplerate
200 n_channels = input_file.channels
File c:\users\bahar\appdata\local\programs\python\python39\lib\site-packages\audioread\__init__.py:116, in audio_open(path, backends)
113 pass
115 # All backends failed!
--> 116raise NoBackendError()
NoBackendError:
Brian McFee
unread,
Mar 21, 2022, 7:50:58 AM3/21/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to librosa
It looks like you don't have any decoders installed which can handle mp3.
You'll need to install gstreamer or ffmpeg to work with audioread. I generally recommend using the conda packages for this, though it looks like you're not in a conda environment.