Docker部署FunASR(window11系统 )

1、FunASR介绍

FunASR提供可便捷本地或者云端服务器部署的离线文件转写服务,内核为FunASR已开源runtime-SDK。 集成了达摩院语音实验室在Modelscope社区开源的语音端点检测(VAD)、Paraformer-large语音识别(ASR)、标点恢复(PUNC) 等相关能力,拥有完整的语音识别链路,可以将几十个小时的音频或视频识别成带标点的文字,而且支持上百路请求同时进行转写。

2、系统环境安装

2.1 环境要求

2.2 环境设置

打开【控制面板】,点击【程序】

点击【启动或关闭Windows功能】

开启【Hyper-V】、【虚拟机平台】和【适用于Linux的Windows子系统】

开启完毕后,【立即重新启动】

2.3 软件环境安装

2.3.1 docker部署

可以根据云盘地址下载:

http://链接: https://pan.baidu.com/s/1n_Ngu2HN_tIiMBFiJuljng?pwd=hc3v 提取码: hc3v 复制这段内容后打开百度网盘手机App,操作更方便哦 --来自百度网盘超级会员v5的分享

等待加载完成后,勾选【Install required Windows components for WSL 2
Add shortcut to desktop】,点击【ok】

等待安装完成

在桌面上打开【Docker Desktop】,首次打开需要同意用户协议,勾选用户协议,点击【accept】

点击【设置】,确保每个选项都处于勾选状态

3、服务部署

3.1在 Win11 使用 Docker 部署 FunASR 服务器


该文章因官网文档不详细故写的经验论
官网文章:https://github.com/alibaba-damo-academy/FunASR/blob/main/runtime/docs/SDK_advanced_guide_online_zh.md
且官网只针对 Linux/Max 系统出的教程,故利用Win11记录

在d盘新建    D://FunASR//model   目录

 打开cmd命令行窗口。输入以下命令

(1)跳转到D盘

d:

(2)拉取镜像 

docker pull registry.cn-hangzhou.aliyuncs.com/funasr_repo/funasr:funasr-runtime-sdk-online-cpu-0.1.9

 (3)运行ocker


docker run -p 10095:10095 -it --privileged=true -v D:/FunASR/model:/workspace/models registry.cn-hangzhou.aliyuncs.com/funasr_repo/funasr:funasr-runtime-sdk-online-cpu-0.1.9

 命令行解释:

docker pull 拉取镜像
docker run 启动镜像
-p 10095:10095 将容器内部的端口 10095 映射到宿主机的端口 10095
-it 分配一个伪终端并保持标准输入打开
--privileged=true 赋予容器特权,允许它执行特权操作,如访问宿主机的硬件设备等
-v D:/FunASR/model:/workspace/models 将本地文件系统中的 D:/FunASR/model 目录挂载到容器内的 /workspace/models 目录,实现本地文件与容器内部的文件共享
registry.cn-hangzhou.aliyuncs.com/funasr_repo/funasr:funasr-runtime-sdk-online-cpu-0.1.9 拉取下来的镜像

 下载文件

# 在 /workspace/models 目录下创建一个目录 funasr_samples
mkdir /workspace/models/funasr_samples
# 解压文件到 /workspace/models/funasr_samples 目录下
tar -xzf funasr_samples.tar.gz -C /workspace/models/funasr_samples

3.2 服务端启动

docker启动之后,启动 funasr-wss-server-2pass服务程序:

cd FunASR/runtime
nohup bash run_server_2pass.sh \
  --certfile 0  \
  --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 \
  --itn-dir thuduj12/fst_itn_zh > log.txt 2>&1 &



# 如果您想关闭ssl,增加参数:--certfile 0
# 如果您想使用时间戳或者nn热词模型进行部署,请设置--model-dir为对应模型:
#   damo/speech_paraformer-large-vad-punc_asr_nat-zh-cn-16k-common-vocab8404-onnx(时间戳)
#   damo/speech_paraformer-large-contextual_asr_nat-zh-cn-16k-common-vocab8404-onnx(nn热词)
# 如果您想在服务端加载热词,请在宿主机文件./funasr-runtime-resources/models/hotwords.txt配置热词(docker映射地址为/workspace/models/hotwords.txt):
#   每行一个热词,格式(热词 权重):阿里巴巴 20(注:热词理论上无限制,但为了兼顾性能和效果,建议热词长度不超过10,个数不超过1k,权重1~100)

run_server_2pass.sh命令参数介绍

--download-model-dir 模型下载地址,通过设置model ID从Modelscope下载模型
--model-dir  modelscope model ID 或者 本地模型路径
--online-model-dir  modelscope model ID 或者 本地模型路径
--vad-dir  modelscope model ID 或者 本地模型路径
--punc-dir  modelscope model ID 或者 本地模型路径
--lm-dir modelscope model ID 或者 本地模型路径
--itn-dir modelscope model ID 或者 本地模型路径
--port  服务端监听的端口号,默认为 10095
--decoder-thread-num  服务端线程池个数(支持的最大并发路数),
                      脚本会根据服务器线程数自动配置decoder-thread-num、io-thread-num
--io-thread-num  服务端启动的IO线程数
--model-thread-num  每路识别的内部线程数(控制ONNX模型的并行),默认为 1,
                    其中建议 decoder-thread-num*model-thread-num 等于总线程数
--certfile  ssl的证书文件,默认为:../../../ssl_key/server.crt,如果需要关闭ssl,参数设置为0
--keyfile   ssl的密钥文件,默认为:../../../ssl_key/server.key
--hotword   热词文件路径,每行一个热词,格式:热词 权重(例如:阿里巴巴 20),
            如果客户端提供热词,则与客户端提供的热词合并一起使用,服务端热词全局生效,客户端热词只针对对应客户端生效。

3.3 监控服务端日志

tail -f /workspace/FunASR/runtime/log.txt

前面镜像启动时,我们将容器的目录 /workspace/models 挂载到了宿主机的 D:/FunASR/model 下面,因此下载到 /workspace/models/funasr_samples 目录里面的内容,可以在 D:/FunASR/model 上面看到

3.4 html 连接ASR服务端

修改asr服务器地址为 ws://127.0.0.1:10095/,因为没有开启 SSL,所以不是 wss 而是 ws,使用本地地址 127.0.0.1,端口号为镜像启动时配置的,与宿主机映射的端口号对应

3.5 python 连接ASR服务端

打开miniforge或者anaconda的窗口

安装websocket

pip install websocket

跳转路径 

d:
cd D:\FunASR\model\funasr_samples\samples\python

运行命令,开启识别: 

python3 funasr_wss_client.py --host “127.0.0.1” --port 10095 --mode 2pass --ssl 0

4、linux安装FunASR

Docker安装部署FunASR (linux版本)-CSDN博客

文章借鉴:

轻松搞定!在 Windows 10 上安装 FunASR 并运行离线时间戳模型-CSDN博客

【语音识别】在Win11使用Docker部署FunASR服务器_funasr docker-CSDN博客

  • 24
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值