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

参考自:

阿里达摩院

服务端

安装 Docker

(过程省略)

下面步骤如果是在 Linux 需要以管理员方式执行命令,开头添加 sudo

docker 拉取镜像

bash 复制代码
docker pull registry.cn-hangzhou.aliyuncs.com/funasr_repo/funasr:funasr-runtime-sdk-cpu-0.4.4

创建模型目录

bash 复制代码
mkdir -p ./funasr-runtime-resources/models

运行 docker 镜像

bash 复制代码
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

启动服务

bash 复制代码
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)

客户端

下载客户端测试工具

bash 复制代码
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

bash 复制代码
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

https://www.python.org/ftp/python/3.11.8/python-3.11.8-amd64.exe

pip 安装依赖库

bash 复制代码
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

运行客户端

bash 复制代码
# 这个目录取决于上面你解压的文件所在的目录
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 脚本


更多内容和文档,详见:alibaba-damo-academy/FunASR (github.com)

相关推荐
天远API3 分钟前
零信任架构实战:基于天远单人婚姻查询构建自动化保障房准入审核网关
运维·人工智能·架构·自动化
CDA数据分析师干货分享12 分钟前
AI会取代会计吗?未来哪些财务岗位更容易受到AI冲击?
大数据·人工智能·财务·cda证书·cda数据分析
沐飞工具箱36 分钟前
从 SEO 到 GEO:AI 搜索如何理解网页内容?一次完整的可见性测试实践
大数据·人工智能·新媒体运营·内容运营
骑着蜗牛撵大象3271 小时前
AI Agent 工程化开发实战(十四):拆开 Deep Agents 看家底——计划、子代理与文件系统内置了什么
人工智能·架构·langgraph·mcp·deepagents·子代理
lingyubb1 小时前
适合短视频配音 操作简单的AI配音软件推荐怎么落地?从文案到成片的四步实操拆解
人工智能·音视频·状态模式
上弦外贸新观察1 小时前
ChatGPT广告服务商哪家好?分享OpenAI广告业务服务评估思路,从平台政策核实、账户支持、广告策略到运营流程逐项了解
人工智能·chatgpt
镜象科技2 小时前
大学AI心理健康解决方案服务商的危机联动设计:从宿舍楼到精神科的多方接力
人工智能
硅谷秋水2 小时前
Gemini Robotics 1.5 将 AI 智能体引入物理世界
人工智能·机器学习·语言模型·机器人
具身AGI2 小时前
物理AI 人类学习路线:三大判断怎么兑现
大数据·人工智能·学习
智购科技无人售货机工厂店2 小时前
自动售货机振动与运输可靠性测试实战:跌落、振动与包装~YH
java·大数据·服务器·人工智能·科技