我正在一个项目上,但是我的问题是我的librosa库向我显示找不到该文件,但是它存在。
# Load using Librosa
y, sr = librosa.load(normal_file, duration=5) #default sampling rate is 22 HZ
dur=librosa.get_duration(y)
print ("duration:", dur)
print(y.shape, sr)
错误:
FileNotFoundError
Traceback (most recent call last)
<ipython-input-31-d400d9a9c828> in <module>()
1 # Load using Librosa
----> 2 y, sr = librosa.load(normal_file) #default sampling rate is 22 HZ
3 dur=librosa.get_duration(y)
4 print ("duration:", dur)
5 print(y.shape, sr)
~\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
~\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:
~\Anaconda3\lib\site-packages\audioread\__init__.py in available_backends()
84
85 # FFmpeg.
---> 86 if ffdec.available():
87 result.append(ffdec.FFmpegAudioFile)
88
~\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()
~\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:
~\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)
707 c2pread, c2pwrite,
708 errread, errwrite,
--> 709 restore_signals, start_new_session)
710 except:
711 # Cleanup if the child failed starting.
~\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)
995 env,
996 os.fspath(cwd) if cwd is not None else None,
--> 997 startupinfo)
998 finally:
999 # Child is launched. Close the parent's copy of those pipe
FileNotFoundError: [WinError 2] The system cannot find the file specified
它显示持续时间并读取音频文件。