如何解决Librosa无法识别文件.wav,.mp3Pycharm MacOS
我想将Pycharm与librosa一起使用以绘制某种类型的音频文件的波形,但是我一直在加载文件时遇到麻烦。当我开始运行它时,我得到了这个错误:
/Users/username/Desktop/example/venv/lib/python3.7/site-packages/librosa/core/audio.py:162: UserWarning: PySoundFile failed. Trying audioread instead.
warnings.warn("PySoundFile failed. Trying audioread instead.")
Traceback (most recent call last):
File "/Users/username/example/venv/lib/python3.7/site-packages/librosa/core/audio.py",line 146,in load
with sf.SoundFile(path) as sf_desc:
File "/Users/username/Desktop/example/venv/lib/python3.7/site-packages/soundfile.py",line 629,in __init__
self._file = self._open(file,mode_int,closefd)
File "/Users/username/Desktop/example/venv/lib/python3.7/site-packages/soundfile.py",line 1184,in _open
"Error opening {0!r}: ".format(self.name))
File "/Users/username/Desktop/example/venv/lib/python3.7/site-packages/soundfile.py",line 1357,in _error_check
raise RuntimeError(prefix + _ffi.string(err_str).decode('utf-8','replace'))
RuntimeError: Error opening 'audiofile.filetype': System error.
During handling of the above exception,another exception occurred:
Traceback (most recent call last):
File "/Users/username/Desktop/example/main.py",line 6,in <module>
y,sr = lr.load('audiofile.filetype',sr=None)
File "/Users/username/Desktop/example/venv/lib/python3.7/site-packages/librosa/core/audio.py",line 163,in load
y,sr_native = __audioread_load(path,offset,duration,dtype)
File "/Users/username/Desktop/example/venv/lib/python3.7/site-packages/librosa/core/audio.py",line 187,in __audioread_load
with audioread.audio_open(path) as input_file:
File "/Users/username/Desktop/example/venv/lib/python3.7/site-packages/audioread/__init__.py",line 111,in audio_open
return BackendClass(path)
File "/Users/username/Desktop/example/venv/lib/python3.7/site-packages/audioread/rawread.py",line 62,in __init__
self._fh = open(filename,'rb')
FileNotFoundError: [Errno 2] No such file or directory: '2 octaves.mp3'
Process finished with exit code 1
这就是我在main.py中输入的内容
import librosa as lr
import librosa.display as ld
import matplotlib.pyplot as plt
# load mp3 doc
y,sr = lr.load('2 octaves.mp3',sr=None)
# plot a mp3form
plt.figure()
ld.waveplot(y,sr)
plt.title('Beat mp3form')
plt.show()
并且我尝试将 audioread
中的subprocess.Popen(cmd,*args,**kwargs,shell)
中的return subprocess.Popen(cmd,shell = True)
替换为ffdec.py
如果您知道如何解决此问题,请在下面帮助我并发表评论,谢谢!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。