阿里SenseVoice -语音识别模型本地部署

0 阅读3分钟

阿里SenseVoice -语音识别模型本地部署

1.1 地址:

官网地址:

FunAudioLLM Homepage

开源项目地址:

github.com/FunAudioLLM…

推荐使用Python 3.8 ~ 3.11,因为大多数深度学习/语音处理项目(如 SenseVoice)通常要求 Python 3.8 ~ 3.11。

1.2 安装python环境

#创建python虚拟环境
cd SenseVoice/
# 创建一个名为venv 的虚拟环境。
python -m venv .venv
#进入虚拟环境
.venv\Scripts\activate
 
#安装依赖
pip install -r requirements.txt

1.3 模型下载

modelscope download --model iic/SenseVoiceSmall --local_dir model/iic/SenseVoiceSmall
 
modelscope download --model iic/speech_fsmn_vad_zh-cn-16k-common-pytorch --local_dir model/iic/speech_fsmn_vad_zh-cn-16k-common-pytorch

1.4运行

#切换到虚拟环境才能运行
..venv\Scripts\activate
 
#运行webui用这个
python webui.py
 
#运行demo用这个
#python demo1.py

参考资料:阿里SenseVoice -语音识别模型本地部署_sensevoice部署-CSDN博客

2安装出现的问题

这些问题是我配置时出现的一些问题,给君参考

2.1

Q:

(.venv) C:\Program Files\SenseVoice-main>pip install -r requirements.txt ERROR: Could not find a version that satisfies the requirement torch<=2.3 (from versions: 2.9.0, 2.9.1, 2.10.0, 2.11.0) ERROR: No matching distribution found for torch<=2.3

这个错误是因为你的 requirements.txt 中指定了 torch<=2.3,但当前你使用的 pip 源(默认是 PyPI)中可用的 torch 版本只有 2.9.0 及以上,没有满足 ≤2.3 的旧版本。这通常发生在 PyTorch 官方不再通过 PyPI 提供旧版本(或者你的 pip 源只缓存了新版)的情况下。
我这里的解决是修改了 requirements.txt文件,将 torch<=2.3 改为 torch>=2.0

2.1

Q:

Failed to build editdistance error: failed-wheel-build-for-install × Failed to build installable wheels for some pyproject.toml based projects ╰─> editdistance

这个错误是因为 editdistance 是一个包含 C++ 代码的库,在 Windows 上使用 pip 安装时,需要本地有 C++ 编译器才能将源码编译成二进制文件。你的系统当前缺少这个编译环境。

  1. 下载安装程序:访问微软官方网站,搜索并下载 “Microsoft C++ Build Tools”。

  2. 安装关键组件:运行安装程序,在“工作负载”(Workloads)选项卡中,勾选 “使用 C++ 的桌面开发” 。在右侧的“安装详细信息”中,确保 Windows 10/11 SDK 也被选中

    这一步会自动安装所需的 C++ 编译器(cl.exe)、链接器和 Windows 头文件。

  3. 重启并重试:安装完成后,重启电脑,然后重新激活你的虚拟环境并再次运行安装命令

2.3

Q:

RuntimeError: Cannot load audio from file: `ffprobe` not found. Please install `ffmpeg` in your system to use non-WAV audio file formats and make sure `ffprobe` is in your PATH.

这个错误是因为 Gradio 在处理音频文件时需要调用 ffprobe 来读取音频信息,但你的系统中没有安装 FFmpeg 工具包(其中包含 ffprobe)。
你需要安装 FFmpeg 并将其添加到系统环境变量 PATH 中。

从官网下载 FFmpeg 官方下载

Pasted image 20260329083652.png 下载时请注意选择文件名中带有 shared 或 full_build 的版本,例如:ffmpeg-release-full.7z。这些是已经编译好的、可以直接运行的版本

不要下载 以 -source 结尾的文件,那是需要你自己手动编译的源代码包。
(不要在绿色的按钮处下载)

image.png

然后解压文件,并找到bin文件夹,确认里面有三个 .exe 文件:ffmpeg.exeffprobe.exe 和 ffplay.exe
复制这个bin文件夹的完整路径(例如 C:\Users\你的用户名\Downloads\ffmpeg-7.0.2-full_build\bin),然后添加到环境变量里面去。