Skip to content

运行demo1.py音频加载报错,必须安装ffmpeg吗? #81

@buaalyx

Description

@buaalyx

运行demo1.py,遇到如下报错

ERROR:root:Loading wav failed! [Errno 2] No such file or directory: 'ffmpeg', Traceback (most recent call last):
File "/root/anaconda3/envs/env0128/lib/python3.10/site-packages/torchaudio/_torchcodec.py", line 82, in load_with_torchcodec
from torchcodec.decoders import AudioDecoder
ModuleNotFoundError: No module named 'torchcodec'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/root/anaconda3/envs/env0128/lib/python3.10/site-packages/funasr/utils/load_utils.py", line 101, in load_audio_text_image_video
data_or_path_or_list, audio_fs = torchaudio.load(data_or_path_or_list)
File "/root/anaconda3/envs/env0128/lib/python3.10/site-packages/torchaudio/init.py", line 86, in load
return load_with_torchcodec(
File "/root/anaconda3/envs/env0128/lib/python3.10/site-packages/torchaudio/_torchcodec.py", line 84, in load_with_torchcodec
raise ImportError(
ImportError: TorchCodec is required for load_with_torchcodec. Please install torchcodec to use this function.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/workdir/model/Fun-ASR-main/model.py", line 380, in data_load_speech
data_src = load_audio_text_image_video(
File "/root/anaconda3/envs/env0128/lib/python3.10/site-packages/funasr/utils/load_utils.py", line 105, in load_audio_text_image_video
data_or_path_or_list = _load_audio_ffmpeg(data_or_path_or_list, sr=fs)
File "/root/anaconda3/envs/env0128/lib/python3.10/site-packages/funasr/utils/load_utils.py", line 266, in _load_audio_ffmpeg
out = run(cmd, capture_output=True, check=True).stdout
File "/root/anaconda3/envs/env0128/lib/python3.10/subprocess.py", line 503, in run
with Popen(*popenargs, **kwargs) as process:
File "/root/anaconda3/envs/env0128/lib/python3.10/subprocess.py", line 971, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "/root/anaconda3/envs/env0128/lib/python3.10/subprocess.py", line 1863, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg'

Traceback (most recent call last):
File "/workdir/model/Fun-ASR-main/demo1.py", line 56, in
main()
File "/workdir/model/Fun-ASR-main/demo1.py", line 26, in main
res = model.generate(
File "/root/anaconda3/envs/env0128/lib/python3.10/site-packages/funasr/auto/auto_model.py", line 324, in generate
return self.inference(
File "/root/anaconda3/envs/env0128/lib/python3.10/site-packages/funasr/auto/auto_model.py", line 381, in inference
res = model.inference(**batch, **kwargs)
File "/workdir/model/Fun-ASR-main/model.py", line 603, in inference
return self.inference_llm(
File "/workdir/model/Fun-ASR-main/model.py", line 621, in inference_llm
inputs_embeds, contents, batch, source_ids, meta_data = self.inference_prepare(
File "/workdir/model/Fun-ASR-main/model.py", line 476, in inference_prepare
output = self.data_load_speech(contents, tokenizer, frontend, meta_data=meta_data, **kwargs)
File "/workdir/model/Fun-ASR-main/model.py", line 389, in data_load_speech
data_src,
UnboundLocalError: local variable 'data_src' referenced before assignment

以下是环境信息,torchaudio已经安装了:
Package Version


aliyun-python-sdk-core 2.16.0
aliyun-python-sdk-kms 2.16.5
antlr4-python3-runtime 4.9.3
anyio 4.12.1
audioread 3.1.0
certifi 2026.1.4
cffi 2.0.0
charset-normalizer 3.4.4
click 8.3.1
compute-wer 0.2.3
crcmod 1.7
cryptography 46.0.3
cuda-bindings 12.9.4
cuda-pathfinder 1.3.3
decorator 5.2.1
edit-distance 1.0.7
editdistance 0.8.1
exceptiongroup 1.3.1
ffmpeg-python 0.2.0
filelock 3.20.3
fsspec 2026.1.0
funasr 1.3.1
future 1.0.0
h11 0.16.0
hf-xet 1.2.0
httpcore 1.0.9
httpx 0.28.1
huggingface_hub 1.3.4
hydra-core 1.3.2
idna 3.11
ImageIO 2.37.2
imageio-ffmpeg 0.6.0
indic_numtowords 1.1.0
jaconv 0.4.1
jamo 0.4.1
jieba 0.42.1
Jinja2 3.1.6
jmespath 0.10.0
joblib 1.5.3
kaldiio 2.18.1
lazy_loader 0.4
librosa 0.11.0
llvmlite 0.46.0
MarkupSafe 3.0.3
modelscope 1.34.0
more-itertools 10.8.0
moviepy 2.2.1
mpmath 1.3.0
msgpack 1.1.2
networkx 3.4.2
numba 0.63.1
numpy 2.2.6
nvidia-cublas-cu12 12.8.4.1
nvidia-cuda-cupti-cu12 12.8.90
nvidia-cuda-nvrtc-cu12 12.8.93
nvidia-cuda-runtime-cu12 12.8.90
nvidia-cudnn-cu12 9.10.2.21
nvidia-cufft-cu12 11.3.3.83
nvidia-cufile-cu12 1.13.1.3
nvidia-curand-cu12 10.3.9.90
nvidia-cusolver-cu12 11.7.3.90
nvidia-cusparse-cu12 12.5.8.93
nvidia-cusparselt-cu12 0.7.1
nvidia-nccl-cu12 2.27.5
nvidia-nvjitlink-cu12 12.8.93
nvidia-nvshmem-cu12 3.4.5
nvidia-nvtx-cu12 12.8.90
omegaconf 2.3.0
openai-whisper 20250625
oss2 2.19.1
packaging 25.0
pillow 11.3.0
pip 25.3
platformdirs 4.5.1
pooch 1.8.2
proglog 0.1.12
protobuf 6.33.4
pycparser 3.0
pycryptodome 3.23.0
pynndescent 0.6.0
pyopenjtalk-plus 0.4.1.post7
python-dotenv 1.2.1
pytorch-wpe 0.0.1
PyYAML 6.0.3
regex 2026.1.15
requests 2.32.5
safetensors 0.7.0
scikit-learn 1.7.2
scipy 1.15.3
sentencepiece 0.2.1
setuptools 80.10.1
shellingham 1.5.4
six 1.17.0
soundfile 0.13.1
soxr 1.0.0
SudachiDict-core 20260116
SudachiPy 0.6.10
sympy 1.14.0
tensorboardX 2.6.4
threadpoolctl 3.6.0
tiktoken 0.12.0
tokenizers 0.22.2
torch 2.10.0
torch-complex 0.4.4
torchaudio 2.10.0
tqdm 4.67.1
transformers 5.0.0
triton 3.6.0
typer-slim 0.21.1
typing_extensions 4.15.0
umap-learn 0.5.11
urllib3 2.6.3
wheel 0.46.3
whisper_normalizer 0.1.12
zhconv 1.4.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions