import librosa
import librosa.display
import IPython.display
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
import matplotlib.font_manager as fm
audio_path = 'rec.wav'
y, sr = librosa.load(audio_path)
I tried to load the audio file into librosa. So I wrote the code like that. But I get the error "File contains data in an unknown format", "File contains data in an unknown format".
I searched on Google and I was told to install ffmpeg. So I installed ffmpeg but still get the error
What's wrong? (I guess there is a problem with the encoding.........)
all error messege:
Traceback (most recent call last):
File "C:\Users\****\AppData\Local\Programs\Python\Python36\lib\site-packages\librosa\core\audio.py", line 129, in load
with sf.SoundFile(path) as sf_desc:
File "C:\Users\****\AppData\Local\Programs\Python\Python36\lib\site-packages\soundfile.py", line 629, in __init__
self._file = self._open(file, mode_int, closefd)
File "C:\Users\****\AppData\Local\Programs\Python\Python36\lib\site-packages\soundfile.py", line 1184, in _open
"Error opening {0!r}: ".format(self.name))
File "C:\Users\****\AppData\Local\Programs\Python\Python36\lib\site-packages\soundfile.py", line 1357, in _error_check
raise RuntimeError(prefix + _ffi.string(err_str).decode('utf-8', 'replace'))
RuntimeError: Error opening 'rec.mp3': File contains data in an unknown format.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/****/PycharmProjects/pitch_project_/pitdetec.py", line 12, in <module>
y, sr = librosa.load(audio_path)
File "C:\Users\*****\AppData\Local\Programs\Python\Python36\lib\site-packages\librosa\core\audio.py", line 147, in load
y, sr_native = __audioread_load(path, offset, duration, dtype)
File "C:\Users\****\AppData\Local\Programs\Python\Python36\lib\site-packages\librosa\core\audio.py", line 171, in __audioread_load
with audioread.audio_open(path) as input_file:
File "C:\Users\****\AppData\Local\Programs\Python\Python36\lib\site-packages\audioread\__init__.py", line 116, in audio_open
raise NoBackendError()
audioread.exceptions.NoBackendError
try:
audio_path = 'C:/Users/ddolcju/PycharmProjects/pitch_project/rec.mp3'