简体   繁体   中英

Error importing librosa for TensorFlow: sndfile library not found

I'm trying to use TensorFlow Lite for a voice recognition project using Jupyter notebook but when I try to do a "import librosa" (using commands found here: https://github.com/ShawnHymel/tflite-speech-recognition/blob/master/01-speech-commands-mfcc-extraction.ipynb ) I keep getting this error:

OSError: sndfile library not found

I've looked for a solution for two days now, tried many different things I've found online but I just can't seem to get it to work.

I'm using CentOS 8 and the tensorflow is running on a 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

My requirements.txt is empty, at least when I do pip freeze > requirements.txt .

pip -V or --v returns this

pip 20.3.2 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)

Trying to install pysndfile gives me this

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.

I've tried different commands to fix this error and to install the sndfile but all of them have given errors or simply said it's already installed.

I do have librosa installed but trying to import it gives me this full error:

 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

Anyone got ideas on how to sort this?

Install sndfile for your operating system. On CentOS that should be yum install libsndfile .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM