问题遇到的现象和发生背景 :对一个github上语音识别模型进行测试运行时,环境都已配置好
问题相关代码,请勿粘贴截图 :出问题的原函数:
def set_audio_backend(backend: Optional[str]):
"""Set the backend for I/O operation
Args:
backend (str or None): Name of the backend.
One of ``"sox_io"`` or ``"soundfile"`` based on availability
of the system. If ``None`` is provided the current backend is unassigned.
"""
if backend is not None and backend not in list_audio_backends():
raise RuntimeError(f'Backend "{backend}" is not one of ' f"available backends: {list_audio_backends()}.")
if backend is None:
module = no_backend
elif backend == "sox_io":
module = sox_io_backend
elif backend == "soundfile":
module = soundfile_backend
else:
raise NotImplementedError(f'Unexpected backend "{backend}"')
for func in ["save", "load", "info"]:
setattr(torchaudio, func, getattr(module, func))
运行结果及报错内容 :
(pytorch) C:\Users\ASUS\PycharmProjects\pythonProject4\deepsp>python transcribe.py model.model_path=models/deepspeech.pth audio_path=/path/audio.wav
'sox' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
SoX could not be found!
If you do not have SoX, proceed here:
- - - http://sox.sourceforge.net/ - - -
If you do (or think that you should) have SoX, double-check your
path variables.
Traceback (most recent call last):
File "transcribe.py", line 5, in <module>
from deepspeech_pytorch.inference import transcribe
File "C:\Users\ASUS\PycharmProjects\pythonProject4\deepsp\deepspeech_pytorch\inference.py", line 10, in <module>
from deepspeech_pytorch.loader.data_loader import SpectrogramParser
File "C:\Users\ASUS\PycharmProjects\pythonProject4\deepsp\deepspeech_pytorch\loader\data_loader.py", line 17, in <module>
torchaudio.set_audio_backend("sox_io")
File "D:\anacoda\envs\pytorch\lib\site-packages\torchaudio\backend\utils.py", line 44, in set_audio_backend
raise RuntimeError(f'Backend "{backend}" is not one of ' f"available backends: {list_audio_backends()}.")
RuntimeError: Backend "sox_io" is not one of available backends: ['soundfile'].
我的解答思路和尝试过的方法
一开始以为sox没装上,检查了一遍,发现装上了,然后看了一下path也设置了
我想要达到的结果:
解决RuntimeError