为 TensorFlow 导入 librosa 时出错:找不到 sndfile 库
Error importing librosa for TensorFlow: sndfile library not found
我正在尝试将 TensorFlow Lite 用于使用 Jupyter notebook 的语音识别项目,但是当我尝试执行“导入 librosa”(使用在此处找到的命令:https://github.com/ShawnHymel/tflite-speech-recognition/blob/master/01-speech-commands-mfcc-extraction.ipynb)时,我不断收到此错误:
OSError: sndfile library not found
我已经寻找了两天的解决方案,尝试了很多我在网上找到的不同的东西,但我似乎无法让它工作。
我正在使用 CentOS 8,tensorflow 在 docker:
上 运行
docker pull tensorflow/tensorflow:latest-py3-jupyter
docker run -it --rm -v /home/server/Desktop/TensorFlow -p 8888:8888 tensorflow/tensorflow:latest-py3-jupyter
我的 requirements.txt 是空的,至少当我做 pip freeze > requirements.txt.
pip -V 或 --v returns 这个
pip 20.3.2 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)
尝试安装 pysndfile 时出现了这个
ERROR: Command errored out with exit status 1: /usr/bin/python3 /usr/local/lib/python3.6/dist-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-w_gdqebo/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools 'numpy>=1.13.0' 'cython>=0.25.0' wheel Check the logs for full command output.
我尝试了不同的命令来修复此错误并安装 sndfile,但它们都给出了错误或者只是说它已经安装了。
我确实安装了 librosa,但尝试导入它时出现以下完整错误:
OSError Traceback (most recent call last)
<ipython-input-10-989066361697> in <module>
----> 1 import librosa
/usr/local/lib/python3.6/dist-packages/librosa/__init__.py in <module>
209 # And all the librosa sub-modules
210 from ._cache import cache
--> 211 from . import core
212 from . import beat
213 from . import decompose
/usr/local/lib/python3.6/dist-packages/librosa/core/__init__.py in <module>
4
5 from .convert import * # pylint: disable=wildcard-import
----> 6 from .audio import * # pylint: disable=wildcard-import
7 from .spectrum import * # pylint: disable=wildcard-import
8 from .pitch import * # pylint: disable=wildcard-import
/usr/local/lib/python3.6/dist-packages/librosa/core/audio.py in <module>
6 import warnings
7
----> 8 import soundfile as sf
9 import audioread
10 import numpy as np
/usr/local/lib/python3.6/dist-packages/soundfile.py in <module>
140 _libname = _find_library('sndfile')
141 if _libname is None:
--> 142 raise OSError('sndfile library not found')
143 _snd = _ffi.dlopen(_libname)
144 except OSError:
OSError: sndfile library not found
有人知道如何排序吗?
为您的操作系统安装 sndfile。在 CentOS 上应该是 yum install libsndfile
.
我正在尝试将 TensorFlow Lite 用于使用 Jupyter notebook 的语音识别项目,但是当我尝试执行“导入 librosa”(使用在此处找到的命令:https://github.com/ShawnHymel/tflite-speech-recognition/blob/master/01-speech-commands-mfcc-extraction.ipynb)时,我不断收到此错误:
OSError: sndfile library not found
我已经寻找了两天的解决方案,尝试了很多我在网上找到的不同的东西,但我似乎无法让它工作。
我正在使用 CentOS 8,tensorflow 在 docker:
上 运行docker pull tensorflow/tensorflow:latest-py3-jupyter
docker run -it --rm -v /home/server/Desktop/TensorFlow -p 8888:8888 tensorflow/tensorflow:latest-py3-jupyter
我的 requirements.txt 是空的,至少当我做 pip freeze > requirements.txt.
pip -V 或 --v returns 这个
pip 20.3.2 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)
尝试安装 pysndfile 时出现了这个
ERROR: Command errored out with exit status 1: /usr/bin/python3 /usr/local/lib/python3.6/dist-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-w_gdqebo/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools 'numpy>=1.13.0' 'cython>=0.25.0' wheel Check the logs for full command output.
我尝试了不同的命令来修复此错误并安装 sndfile,但它们都给出了错误或者只是说它已经安装了。
我确实安装了 librosa,但尝试导入它时出现以下完整错误:
OSError Traceback (most recent call last)
<ipython-input-10-989066361697> in <module>
----> 1 import librosa
/usr/local/lib/python3.6/dist-packages/librosa/__init__.py in <module>
209 # And all the librosa sub-modules
210 from ._cache import cache
--> 211 from . import core
212 from . import beat
213 from . import decompose
/usr/local/lib/python3.6/dist-packages/librosa/core/__init__.py in <module>
4
5 from .convert import * # pylint: disable=wildcard-import
----> 6 from .audio import * # pylint: disable=wildcard-import
7 from .spectrum import * # pylint: disable=wildcard-import
8 from .pitch import * # pylint: disable=wildcard-import
/usr/local/lib/python3.6/dist-packages/librosa/core/audio.py in <module>
6 import warnings
7
----> 8 import soundfile as sf
9 import audioread
10 import numpy as np
/usr/local/lib/python3.6/dist-packages/soundfile.py in <module>
140 _libname = _find_library('sndfile')
141 if _libname is None:
--> 142 raise OSError('sndfile library not found')
143 _snd = _ffi.dlopen(_libname)
144 except OSError:
OSError: sndfile library not found
有人知道如何排序吗?
为您的操作系统安装 sndfile。在 CentOS 上应该是 yum install libsndfile
.