librosa.load:加载文件时找不到文件错误 [英] librosa.load: file not found error on loading a file

查看:793
本文介绍了librosa.load:加载文件时找不到文件错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用librosa分析.wav文件。我从创建一个列表开始,该列表存储了它检测到的所有.wav文件的名称。

I am trying to use librosa to analyze .wav files. I started with creating a list which stores the names of all the .wav files it detected.

data_dir = '/Users/raghav/Desktop/FSU/summer research'
audio_file = glob(data_dir + '/*.wav')

我可以在 audio_file列表中看到所有文件的名称。但是,当我加载任何音频文件时,它给我文件未找到错误。

I can see the names of all the files in the list 'audio_file'. But when I load any of the audio file, it gives me file not found error.

audio, sfreq = lr.load(audio_file[0])






错误输出:


error output:

Traceback (most recent call last):
  File "read_audio.py", line 10, in <module>
    audio, sfreq = lr.load(audio_file[1])
  File "/usr/local/lib/python3.7/site-packages/librosa/core/audio.py", line 119, in load
    with audioread.audio_open(os.path.realpath(path)) as input_file:    
  File "/usr/local/lib/python3.7/site-packages/audioread/__init__.py", line 107, in audio_open
    backends = available_backends()
  File "/usr/local/lib/python3.7/site-packages/audioread/__init__.py", line 86, in available_backends
    if ffdec.available():
  File "/usr/local/lib/python3.7/site-packages/audioread/ffdec.py", line 108, in available
    creationflags=PROC_FLAGS,
  File "/usr/local/lib/python3.7/site-packages/audioread/ffdec.py", line 94, in popen_multiple
    return subprocess.Popen(cmd, *args, **kwargs)
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 775, in __init__
    restore_signals, start_new_session)
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1522, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)

FileNotFoundError: [Errno 2] No such file or directory: 'avconv': 'avconv'


推荐答案

两件事:


  1. 您似乎正在使用自制软件

  2. avconv 不在您的路径中

  1. It looks like you are using Homebrew
  2. avconv is not in your path

假设您从未安装过它,那么应该只需安装即可解决此问题。即运行:

Assuming, you have never installed it, you should be able to solve this simply by installing it. I.e. run:

$ brew install libav

(请参见此处

如果已经安装了 avconv ,则可能需要查看 PATH 环境,并检查其是否在

If avconv is already installed, you probably need to look into your PATH environment and check whether it is in the path.

也就是说,使用Homebrew安装的系统级Python是一个坏主意,因为它不能快速让您更改Python版本和依赖集。在数周之内,一切都变得一团糟。

That said, using a system-wide Python as installed by Homebrew is a bad idea, because it does not quickly let you change Python versions and dependency sets. It all becomes one big mess within weeks.

一个(多个)解决方案是使用 miniconda

One (among multiple) solutions for this is to use miniconda. It quickly lets you activate Python interpreters with defined dependency sets.

因此,要真正解决该问题,我建议安装 miniconda 并创建一个普通的Python 3.6环境:

So to really solve the issue, I'd recommend to install miniconda and create a plain Python 3.6 environment:

$ conda create -n librosa_env python=3.6

激活环境:

$ source activate librosa_env

然后添加 conda-forge 频道(包含许多库的存储库,例如 librosa ):

Then add the conda-forge channel (a repository that contains many libraries like librosa):

$ conda config --add channels conda-forge

然后安装 librosa

$ conda install librosa

通过这种方式安装librosa, conda 应该照顾所有的依赖,包括。 libav

By installing librosa this way, conda should take care of all dependencies, incl. libav.

这篇关于librosa.load:加载文件时找不到文件错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆