关于FunASR
FunASR是一个基础语音识别工具包,提供多种功能,包括语音识别(ASR)、语音端点检测(VAD)、标点恢复、语言模型、说话人验证、说话人分离和多人对话语音识别等。FunASR提供了便捷的脚本和教程,支持预训练好的模型的推理与微调。
环境信息
| 配置 |
操作系统 |
IP地址 |
| 32 vCPUs 256GB | g8t.8xlarge256 | 直通型GPU: 4 * T4(64GB) |
CentOS7.9 |
192.168.1.36(私网) 36.251.168.42(公网) |
部署FunASR离线文件转写服务CPU版本
安装Docker
说明
如果您已安装Docker,忽略本步骤!!
二进制包下载地址:https://download.docker.com/linux/static/stable/
到对应平台的目录下载所需版本的Docker二进制包,并上传到/root目录下(本文以x86平台下的29.0.0为例),然后执行以下命令安装Docker
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| cd /root/ tar zxf docker-29.0.0.tgz chmod 755 docker/* cp -a docker/* /usr/bin/
cat > /usr/lib/systemd/system/docker.service << EOF [Unit] Description=Docker Application Container Engine Documentation=https://docs.docker.com After=network-online.target firewalld.service containerd.service Wants=network-online.target
[Service] Type=notify ExecStart=/usr/bin/dockerd ExecReload=/bin/kill -s HUP \$MAINPID TimeoutSec=0 RestartSec=2 Restart=always StartLimitBurst=3 StartLimitInterval=60s LimitNOFILE=1048576 LimitNPROC=1048576 LimitCORE=infinity TasksMax=infinity Delegate=yes KillMode=process
[Install] WantedBy=multi-user.target EOF
mkdir -p /etc/docker cat > /etc/docker/daemon.json <<EOF { "registry-mirrors": ["https://lerc8rqe.mirror.aliyuncs.com"], "exec-opts": ["native.cgroupdriver=systemd"] } EOF
systemctl daemon-reload systemctl start docker systemctl enable docker systemctl status docker
|
拉取镜像
1
| docker pull registry.cn-hangzhou.aliyuncs.com/funasr_repo/funasr:funasr-runtime-sdk-cpu-0.4.7
|
创建模型目录并启动镜像
1 2 3 4 5 6 7 8 9 10 11
| mkdir -p /data/funasr-runtime-resources/models
docker run -p 10095:10095 -itd --privileged=true \ -v /data/funasr-runtime-resources/models:/workspace/models \ --name funasr-runtime-sdk-cpu-0.4.7 \ registry.cn-hangzhou.aliyuncs.com/funasr_repo/funasr:funasr-runtime-sdk-cpu-0.4.7 /bin/bash
|
启动服务端
容器启动后,进入到Docker容器里启动funasr-wss-server服务程序
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| docker exec -ti funasr-runtime-sdk-cpu-0.4.7 bash
cd /workspace/FunASR/runtime nohup bash run_server.sh \ --download-model-dir /workspace/models \ --vad-dir damo/speech_fsmn_vad_zh-cn-16k-common-onnx \ --model-dir damo/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-onnx \ --punc-dir damo/punc_ct-transformer_cn-en-common-vocab471067-large-onnx \ --lm-dir damo/speech_ngram_lm_zh-cn-ai-wesp-fst \ --itn-dir thuduj12/fst_itn_zh \ --certfile 0 \ --hotword /workspace/models/hotwords.txt > log.txt 2>&1 &
tail -f log.txt
|
当出现如下信息说明funasr-wss-server服务程序已成功启动,并监听在10095端口。
1 2 3 4 5 6 7 8
| ...... I20251114 14:49:19.932682 97 websocket-server.cpp:423] model successfully inited I20251114 14:49:19.932689 97 websocket-server.cpp:425] initAsr run check_and_clean_connection I20251114 14:49:19.932801 97 websocket-server.cpp:428] initAsr run check_and_clean_connection finished I20251114 14:49:19.932811 97 funasr-wss-server.cpp:513] decoder-thread-num: 32 I20251114 14:49:19.932817 97 funasr-wss-server.cpp:514] io-thread-num: 2 I20251114 14:49:19.932823 97 funasr-wss-server.cpp:515] model-thread-num: 1 I20251114 14:49:19.932829 97 funasr-wss-server.cpp:516] asr model init finished. listen on port:10095
|
客户端测试与使用
下载测试工具并解压,在浏览器中打开samples/html/static/index.html,出现如下页面。“asr服务器地址”填写“ws://<IP>:<Port>/”(本文为“ws://36.251.168.42:10095/”),“录音模式”选择“文件”,点击“选择文件”上传工具包中的测试音频(samples/audio),最后点击“连接”进行体验
说明
如果启动funasr-wss-server服务程序时开启了SSL,则填写“asr服务器地址”时协议需修改为“wss”,如“wss://<IP>:<Port>/”

说明
除了网页版本,测试工具还支持Python、CPP和JAVA等编程语言,详细可以参考文档(点击此处)
部署FunASR离线文件转写服务GPU版本
安装显卡驱动和CUDA
说明
如果显卡驱动已安装,忽略本步骤!!
下载显卡驱动和CUDA安装包
访问Download The Official NVIDIA Drivers | NVIDIA,根据实际情况选择对应的显卡型号、平台类型和CUDA版本,点击“Find”

点击“View”

点击“Download”开始下载,待下载完成后上传到服务器/root目录下

查询并禁用nouveau模块
说明
因为nouveau模块会与官方驱动产生兼容性问题,所以需要禁用
执行以下命令查询nouveau模块是否加载
如果加载了nouveau模块,则执行以下命令禁用,否则忽略此步
1 2 3 4 5 6 7 8 9 10
| cat > /usr/lib/modprobe.d/blacklist-nouveau.conf << EOF blacklist nouveau options nouveau modeset=0 EOF
dracut -f systemctl set-default multi-user.target systemctl get-default
|
重启服务器
确认nouveau模块没有启用
安装显卡驱动
1 2 3
| cd /root/ chmod +x NVIDIA-Linux-x86_64-550.163.01.run ./NVIDIA-Linux-x86_64-550.163.01.run
|
验证显卡驱动
执行以下命令可以正常查看到显卡信息说明显卡驱动安装成功
安装Docker
说明
如果您已安装Docker,忽略本步骤!!
二进制包下载地址:https://download.docker.com/linux/static/stable/
到对应平台的目录下载所需版本的Docker二进制包,并上传到/root目录下(本文以x86平台下的29.0.0为例),然后执行以下命令安装Docker
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| cd /root/ tar zxf docker-29.0.0.tgz chmod 755 docker/* cp -a docker/* /usr/bin/
cat > /usr/lib/systemd/system/docker.service << EOF [Unit] Description=Docker Application Container Engine Documentation=https://docs.docker.com After=network-online.target firewalld.service containerd.service Wants=network-online.target
[Service] Type=notify ExecStart=/usr/bin/dockerd ExecReload=/bin/kill -s HUP \$MAINPID TimeoutSec=0 RestartSec=2 Restart=always StartLimitBurst=3 StartLimitInterval=60s LimitNOFILE=1048576 LimitNPROC=1048576 LimitCORE=infinity TasksMax=infinity Delegate=yes KillMode=process
[Install] WantedBy=multi-user.target EOF
mkdir -p /etc/docker cat > /etc/docker/daemon.json <<EOF { "registry-mirrors": ["https://lerc8rqe.mirror.aliyuncs.com"], "exec-opts": ["native.cgroupdriver=systemd"] } EOF
systemctl daemon-reload systemctl start docker systemctl enable docker systemctl status docker
|
配置NVIDIA Container Toolkit YUM源
1 2
| curl -s -L https://nvidia.github.io/libnvidia-container/stable/rpm/nvidia-container-toolkit.repo | \ sudo tee /etc/yum.repos.d/nvidia-container-toolkit.repo
|
安装NVIDIA Container Toolkit软件包
1
| yum install nvidia-container-toolkit -y
|
配置Docker GPU运行环境
说明
配置Docker GPU运行环境需要重启Docker,请确保可以重启Docker再操作
1 2
| nvidia-ctk runtime configure --runtime=docker systemctl restart docker
|
拉取镜像
1
| docker pull registry.cn-hangzhou.aliyuncs.com/funasr_repo/funasr:funasr-runtime-sdk-gpu-0.2.1
|
创建模型目录并启动镜像
1 2 3 4 5 6 7 8 9 10 11 12
| mkdir -p /data/funasr-runtime-resources/models
docker run --gpus=all -p 10095:10095 -itd --privileged=true \ -v /data/funasr-runtime-resources/models:/workspace/models \ --name funasr-runtime-sdk-gpu-0.2.1 \ registry.cn-hangzhou.aliyuncs.com/funasr_repo/funasr:funasr-runtime-sdk-gpu-0.2.1 /bin/bash
|
启动服务端
容器启动后,进入到Docker容器里启动funasr-wss-server服务程序
说明
服务首次启动时会导出torchscript模型,耗时较长,请耐心等待
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| docker exec -ti funasr-runtime-sdk-gpu-0.2.1 bash
cd /workspace/FunASR/runtime nohup bash run_server.sh \ --download-model-dir /workspace/models \ --vad-dir iic/speech_fsmn_vad_zh-cn-16k-common-onnx \ --model-dir iic/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-pytorch \ --punc-dir iic/punc_ct-transformer_cn-en-common-vocab471067-large-onnx \ --lm-dir iic/speech_ngram_lm_zh-cn-ai-wesp-fst \ --itn-dir thuduj12/fst_itn_zh \ --certfile 0 \ --hotword /workspace/models/hotwords.txt > log.txt 2>&1 &
tail -f log.txt
|
当出现如下信息说明funasr-wss-server服务程序已成功启动,并监听在10095端口。
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| ...... I20251117 04:00:35.324638 169 paraformer-torch.cpp:75] Successfully load lm file /workspace/models/iic/speech_ngram_lm_zh-cn-ai-wesp-fst/TLG.fst I20251117 04:00:37.850266 169 ct-transformer.cpp:21] Successfully load model from /workspace/models/iic/punc_ct-transformer_cn-en-common-vocab471067-large-onnx/model_quant.onnx I20251117 04:00:40.247263 169 tokenizer.cpp:40] Successfully load file from /workspace/models/iic/punc_ct-transformer_cn-en-common-vocab471067-large-onnx/jieba.c.dict, /workspace/models/iic/punc_ct-transformer_cn-en-common-vocab471067-large-onnx/jieba_usr_dict I20251117 04:00:40.266239 169 tokenizer.cpp:48] Successfully load model from /workspace/models/iic/punc_ct-transformer_cn-en-common-vocab471067-large-onnx/jieba.hmm I20251117 04:00:40.269872 169 itn-processor.cpp:33] Successfully load model from /workspace/models/thuduj12/fst_itn_zh/zh_itn_tagger.fst I20251117 04:00:40.270870 169 itn-processor.cpp:35] Successfully load model from /workspace/models/thuduj12/fst_itn_zh/zh_itn_verbalizer.fst I20251117 04:00:40.270891 169 websocket-server.cpp:423] model successfully inited I20251117 04:00:40.270898 169 websocket-server.cpp:425] initAsr run check_and_clean_connection I20251117 04:00:40.271036 169 websocket-server.cpp:428] initAsr run check_and_clean_connection finished I20251117 04:00:40.271044 169 funasr-wss-server.cpp:513] decoder-thread-num: 20 I20251117 04:00:40.271050 169 funasr-wss-server.cpp:514] io-thread-num: 2 I20251117 04:00:40.271056 169 funasr-wss-server.cpp:515] model-thread-num: 1 I20251117 04:00:40.271061 169 funasr-wss-server.cpp:516] asr model init finished. listen on port:10095
|
客户端测试与使用
下载测试工具并解压,在浏览器中打开samples/html/static/index.html,出现如下页面。“asr服务器地址”填写“ws://<IP>:<Port>/”(本文为“ws://36.251.168.42:10095/”),“录音模式”选择“文件”,点击“选择文件”上传工具包中的测试音频(samples/audio),最后点击“连接”进行体验
说明
如果启动funasr-wss-server服务程序时开启了SSL,则填写“asr服务器地址”时协议需修改为“wss”,如“wss://<IP>:<Port>/”

说明
除了网页版本,测试工具还支持Python、CPP和JAVA等编程语言,详细可以参考文档(点击此处)