1. 服务器配置
这里是在华为云中租的一台云服务器,用于测试FunASR的支持情况,配置如下表格所示。
| CPU | 内存 | 硬盘 | 系统 |
|---|---|---|---|
| 4核心 | 8GB | 90GB | ky10 |
2. 源码编译FunASR
下载onnxruntime,注意要下载的是arm版本的,而不是x64版本的。
yum update -y
wget https://github.com/microsoft/onnxruntime/releases/download/v1.14.0/onnxruntime-linux-aarch64-1.14.0.tgz
下载ffmpeg,访问官方网站,找到对应的arm架构的ffmpeg下载链接。
将上面的那两个文件下载后,解压。
下载FunASR源码。
git clone https://github.com/modelscope/FunASR.git && cd FunASR/runtime/websocket
然后执行下面的命令。
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=release .. -DONNXRUNTIME_DIR=/opt/downloads/onnxruntime-linux-aarch64-1.16.1 -DFFMPEG_DIR=/opt/downloads/ffmpeg-master-latest-linuxarm64-gpl-shared
make -j 4
编译没有报错,就可以看到如下如所示的内容,如果在执行cmake中途报错,要执行下面的命令删除缓存。
rm -rf CMakeCache.txt CMakeFiles/
在bin目录下就可以看到对应的可执行程序funasr-wss-server-2pass。
3. 下载模型文件
yum -y install git-lfs
git init .
git lfs install
实时语音识别模型
git clone https://www.modelscope.cn/iic/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-online-onnx.git
热词模型
git clone https://www.modelscope.cn/iic/speech_paraformer-large-contextual_asr_nat-zh-cn-16k-common-vocab8404-onnx.git
长音频模型
git clone https://www.modelscope.cn/iic/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-onnx.git
普通模型
git clone https://www.modelscope.cn/iic/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-onnx.git
vad模型
git clone https://www.modelscope.cn/iic/speech_fsmn_vad_zh-cn-16k-common-onnx.git
punc模型
git clone https://www.modelscope.cn/iic/punc_ct-transformer_cn-en-common-vocab471067-large-onnx.git
itn模型
git clone https://www.modelscope.cn/thuduj12/fst_itn_zh.git
Ngram模型
git clone https://www.modelscope.cn/iic/speech_ngram_lm_zh-cn-ai-wesp-fst.git
4. 启动FunASR
./funasr-wss-server-2pass --model-thread-num 4 --decoder-thread-num 4 --io-thread-num 4 --port 8090 --listen-ip 0.0.0.0 --itn-revision master --itn-dir /opt/asr/models/iic/fst_itn_zh --lm-revision master --lm-dir /opt/asr/models/iic/speech_ngram_lm_zh-cn-ai-wesp-fst --punc-revision master --punc-dir /opt/asr/models/iic/punc_ct-transformer_zh-cn-common-vad_realtime-vocab272727-onnx --vad-revision master --vad-dir /opt/asr/models/iic/speech_fsmn_vad_zh-cn-16k-common-onnx --online-model-revision master --offline-model-revision master --online-model-dir /opt/asr/models/iic/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-online-onnx --model-dir /opt/asr/models/iic/speech_paraformer-large-contextual_asr_nat-zh-cn-16k-common-vocab8404-onnx --certfile ""
开放防火墙端口。
firewall-cmd --permanent --add-port=8090/tcp
firewall-cmd --reload
5. 测试
经过上面的步骤,已经在服务器中启动了FunASR的服务端接口,然后就可以在本地电脑启动客户端,连接到这个启动好的服务端接口。
funasr-wss-client-2pass.exe --svs-itn 1 --use-itn 1 --is-ssl 0 --thread-num 8 --mode 2pass --audio-fs 16000 --port 8090 --server-ip 1.95.174.241 --wav-path "E:\test\liziqi.wav"
6. 联系
如需项目合作,可微信搜索lukeewin01,需要备注来意。
Q.E.D.


