我正在尝试使用 torchaudio.load() 读取 m4a 音频文件,但出现以下错误
torchaudio.load("1.m4a")
RuntimeError Traceback (most recent call last)
Cell In[6], line 1
----> 1 torchaudio.load("1.m4a")
File c:\Users\ASUS\Desktop\AI-projects\Voice-Gender-Classification\voiceenv\Lib\site-packages\torchaudio\_backend\utils.py:204, in get_load_func.<locals>.load(uri, frame_offset, num_frames, normalize, channels_first, format, buffer_size, backend)
118 def load(
119 uri: Union[BinaryIO, str, os.PathLike],
120 frame_offset: int = 0,
(...)
126 backend: Optional[str] = None,
127 ) -> Tuple[torch.Tensor, int]:
128 """Load audio data from source.
129
130 By default (``normalize=True``, ``channels_first=True``), this function returns Tensor with
(...)
202 `[channel, time]` else `[time, channel]`.
203 """
--> 204 backend = dispatcher(uri, format, backend)
205 return backend.load(uri, frame_offset, num_frames, normalize, channels_first, format, buffer_size)
File c:\Users\ASUS\Desktop\AI-projects\Voice-Gender-Classification\voiceenv\Lib\site-packages\torchaudio\_backend\utils.py:116, in get_load_func.<locals>.dispatcher(uri, format, backend_name)
114 if backend.can_decode(uri, format):
115 return backend
--> 116 raise RuntimeError(f"Couldn't find appropriate backend to handle uri {uri} and format {format}.")
RuntimeError: Couldn't find appropriate backend to handle uri 1.m4a and format None.
所以我检查了 torchaudio 后端,我得到了一个空列表
import torchaudio
print(torchaudio.list_audio_backends())
[]
我尝试安装 ffmpeg 和 librosa 以及 PySoundFile...但对我来说没有任何作用...
我只是希望它能够正确读取音频文件,以便我可以继续我的项目
https://pytorch.org/audio/stable/installation.html中有一个步骤,如果您从预构建的二进制文件安装它,您仍然需要安装 FFMPEG 库。这是一个伪装成注释的重要步骤,这里引用了它。安装页面上的注释包含每个 FFmpeg 版本的相关链接:
注意
该软件是针对未修改的 FFmpeg 副本编译的,删除了特定的 rpath,以便能够使用系统 图书馆。 LGPL源码可以从以下地址下载 位置:n4.1.8(许可证)、n5.0.3(许可证)和 n6.0(许可证)。