安装FunASR
一、在线实时流式模型服务安装
根据此文档可以安装成功(pull镜像很费时间):
https://github.com/modelscope/FunASR/blob/main/runtime/docs/SDK_advanced_guide_online_zh.md#快速上手
将docker命令改成docker compose file方式:
version: '3.8'
services:
funasr:
# 在线流式模型
image: registry.cn-hangzhou.aliyuncs.com/funasr_repo/funasr:funasr-runtime-sdk-online-cpu-0.1.13
container_name: funasr
ports:
- "10096:10095"
volumes:
- ./funasr-runtime-resources/models:/workspace/models
privileged: true
stdin_open: true # 相当于 -it
tty: true # 相当于 -it
# 运行容器
docker compose up -d
# 进入容器
docker exec -it funasr bash
# 然后执行
cd FunASR/runtime
nohup bash run_server_2pass.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 \
--online-model-dir damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-online-onnx \
--punc-dir damo/punc_ct-transformer_zh-cn-common-vad_realtime-vocab272727-onnx \
--lm-dir damo/speech_ngram_lm_zh-cn-ai-wesp-fst \
--itn-dir thuduj12/fst_itn_zh \
--hotword /workspace/models/hotwords.txt > log.txt 2>&1 &
下载demo:
wget https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/sample/funasr_samples.tar.gz
运行测试, audio_in 参数指定要检测的语音文件,python 得依赖问题和虚拟环境问题,自行另外处理。
python3 /funasr_wss_client.py --host "127.0.0.1" --port 10096 --mode 2pass --audio_in "/test/sample-16k.wav"
二、离线语音识别
将上面docker compose file 的image 镜像替换为:registry.cn-hangzhou.aliyuncs.com/funasr_repo/funasr:funasr-runtime-sdk-cpu-0.4.7
重新build运行容器,然后用命令测试语音识别:
python3 funasr_wss_client.py --host "127.0.0.1" --port 10096 --mode offline --audio_in "../audio/asr_example.wav"
忽律ssl提示,输出类似:
connect to wss://127.0.0.1:10096
pid0_0: demo: 欢迎大家来体验达摩院推出的语音识别模型。 timestamp: [[880,1120],[1120,1380],[1380,1540],[1540,1780],[1780,2020],[2020,2180],[2180,2480],[2480,2600],[2600,2780],[2780,3040],[3040,3240],[3240,3480],[3480,3699],[3699,3900],[3900,4180],[4180,4420],[4420,4620],[4620,4780],[4780,5195]]

浙公网安备 33010602011771号