2

I am trying to read an audio file in Librosa but getting the following error

FileNotFoundError: [WinError 2] The system cannot find the file specified

It is mentioned that somewhere I need to install ffmpeg but it did not solve the problem. I have ffmpeg installed at ffmpeg in c:\programdata\anaconda3\lib\site-packages (1.4).

Here is an example code which I am using to read sample audio file

import librosa
filename = librosa.util.example_audio_file()
print(filename)
y, sr = librosa.load(filename)

It is throwing this error at line number 4

C:\ProgramData\Anaconda3\lib\site-packages\librosa\util\example_data\Kevin_MacLeod_-_Vibe_Ace.ogg
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-7-0780b3498898> in <module>
      1 filename = librosa.util.example_audio_file()
      2 print(filename)
----> 3 y, sr = librosa.load(filename)

C:\ProgramData\Anaconda3\lib\site-packages\librosa\core\audio.py in load(path, sr, mono, offset, duration, dtype, res_type)
    117 
    118     y = []
--> 119     with audioread.audio_open(os.path.realpath(path)) as input_file:
    120         sr_native = input_file.samplerate
    121         n_channels = input_file.channels

C:\ProgramData\Anaconda3\lib\site-packages\audioread\__init__.py in audio_open(path, backends)
    105     """
    106     if backends is None:
--> 107         backends = available_backends()
    108 
    109     for BackendClass in backends:

C:\ProgramData\Anaconda3\lib\site-packages\audioread\__init__.py in available_backends()
     84 
     85     # FFmpeg.
---> 86     if ffdec.available():
     87         result.append(ffdec.FFmpegAudioFile)
     88 

C:\ProgramData\Anaconda3\lib\site-packages\audioread\ffdec.py in available()
    106         stdout=subprocess.PIPE,
    107         stderr=subprocess.PIPE,
--> 108         creationflags=PROC_FLAGS,
    109     )
    110     proc.wait()

C:\ProgramData\Anaconda3\lib\site-packages\audioread\ffdec.py in popen_multiple(commands, command_args, *args, **kwargs)
     92         cmd = [command] + command_args
     93         try:
---> 94             return subprocess.Popen(cmd, *args, **kwargs)
     95         except OSError:
     96             if i == len(commands) - 1:

C:\ProgramData\Anaconda3\lib\subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors, text)
    767                                 c2pread, c2pwrite,
    768                                 errread, errwrite,
--> 769                                 restore_signals, start_new_session)
    770         except:
    771             # Cleanup if the child failed starting.

C:\ProgramData\Anaconda3\lib\subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session)
   1170                                          env,
   1171                                          os.fspath(cwd) if cwd is not None else None,
-> 1172                                          startupinfo)
   1173             finally:
   1174                 # Child is launched. Close the parent's copy of those pipe

FileNotFoundError: [WinError 2] The system cannot find the file specified

I not sure what could be wrong here. Librosa and ffmpeg both are installed but not working at all. Let me know if you need more info.

Samual
  • 512
  • 6
  • 19
  • maybe folder with `ffmpeg` add to variable `PATH` so you could run it in terminal without using full path to `ffmpeg` and then script may not have problem to run it too. – furas May 24 '19 at 10:31

1 Answers1

1

It is solved in the following way Open anaconda promt with admin permission and run following line

conda install -c conda-forge librosa

What was the problem It seems pip install librosa did not work correctly. I needed to install librosa through conda install.

Hope it will help future visitor.

Samual
  • 512
  • 6
  • 19
  • You can create a new user environment and install there. That's also by far the preferred option. Mind that your different projects might have conflicting requirements. Putting everything in one bag is asking for trouble. – Lukasz Tracewski May 24 '19 at 18:36
  • Nope. That is for macOS and mine is in Windows. – Samual May 25 '19 at 08:50