当前位置: 代码网 > it编程>编程语言>其他编程 > 【语音识别】搭建本地的语音转文字系统:FunASR(离线不联网即可使用)

【语音识别】搭建本地的语音转文字系统:FunASR(离线不联网即可使用)

2024年07月28日 其他编程 我要评论
阿里达摩院。

参考自:

服务端

安装 docker

(过程省略)

docker 拉取镜像

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

创建模型目录

mkdir -p ./funasr-runtime-resources/models

运行 docker 镜像

docker run -p 10095:10095 -it --privileged=true -v $pwd/funasr-runtime-resources/models:/workspace/models registry.cn-hangzhou.aliyuncs.com/funasr_repo/funasr:funasr-runtime-sdk-cpu-0.4.4

启动服务

cd 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 \
  --hotword /workspace/models/hotwords.txt > 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)

客户端

下载客户端测试工具

wget https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/maas/asr/sample/funasr_samples.tar.gz

解压上面链接下载的文件。比如我解压到目录 c:\users\z\documents\funasr

解压所在目录下的 funasr_samples\samples 目录为不同类型的语言相关的使用文件

安装 ffmpeg

apt-get install -y ffmpeg  # ubuntu
# yum install -y ffmpeg    # centos
# brew install ffmpeg      # mac
# winget install ffmpeg    # wins

html

解压进入目录:c:\users\z\documents\funasr\funasr_samples\samples\html\static

打开 index.html 使用网页的形式进行操作

python

下载 python

pip 安装依赖库

pip install -u modelscope funasr -i https://mirror.sjtu.edu.cn/pypi/web/simple
pip install -u torchaudio websockets pyaudio ffmpeg-python -i https://mirror.sjtu.edu.cn/pypi/web/simple

运行客户端

# 这个目录取决于上面你解压的文件所在的目录
cd c:\users\z\documents\funasr\runtime\python\websocket

# 识别本地文件
python funasr_wss_client.py --host "127.0.0.1" --port 10095 --mode offline --audio_in "c:\users\z\videos\02d0b6703d9b5d6bc05a46548a938826_new.mp3"

我自己制作了一个使用 python 脚本运行处理的工具,可以下载使用。

下载链接中的 rar 解压后使用: https://github.com/laodie1/godot-funasr-ui/releases

在这里插入图片描述
设置执行的 python,和 funasr_wss 脚本
在这里插入图片描述
注意:识别的文件最好不要超过一个小时,否则可能因为数据太多而返回不回来,造成失败


(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com