当前位置: 首页 > news >正文

从零实现本地语音识别(FunASR)

FunASR 是达摩院开源的综合性语音处理工具包,提供语音识别(ASR)、语音活动检测(VAD)、标点恢复(PUNC)等全流程功能,支持多种主流模型(如 Paraformer、Whisper、SenseVoice)的推理、微调和部署。

1. funasr安装

pip install funasr

在这里插入图片描述
在这里插入图片描述

2. 模型下载

pip install modelscope
modelscope download --model iic/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch

在这里插入图片描述
在这里插入图片描述

3. 依赖库安装

pip install torch torchaudio -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install addict, datasets -i https://pypi.tuna.tsinghua.edu.cn/simple
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

4. 模式一:使用本地模型

4.1 程序编码(本地模型)

from funasr import AutoModelmodel = AutoModel(model="./speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch",disable_update=True,device="cpu"  # 或 "cuda" 如果有GPU
)    
res = model.inference(input="asr_example.wav")
print("识别结果:", res[0]["text"])

4.2. 运行测试(本地模型)

在这里插入图片描述

5. 模式二:运行时自动下载模型

5.1 程序编码(运行时下载模型)

from funasr import AutoModelmodel = AutoModel(model="paraformer-zh",disable_update=True,device="cpu"  # 或 "cuda" 如果有GPU
)    
res = model.inference(input="asr_example.wav")
print("识别结果:", res[0]["text"])

5.2 运行测试(运行时下载模型)

下载后,第二次执行则不再下载,但程序启动会检查。
在这里插入图片描述

6. 模式三:指定vad等子模型

6.1 程序编码(指定子模型)

from funasr import AutoModelmodel = AutoModel(model="paraformer-zh",model_revision="v2.0.4",vad_model="fsmn-vad",punc_model="ct-punc",disable_update=True,device="cpu"  # 或 "cuda" 如果有GPU
)    
res = model.inference(input="asr_example.wav")
print("识别结果:", res[0]["text"])

6.2 运行测试(指定子模型)

在这里插入图片描述

7. 模式四:使用generate

7.1 程序编码(使用generate)

from funasr import AutoModel
import soundfile as sfmodel = AutoModel(model="paraformer-zh",model_revision="v2.0.4",vad_model="fsmn-vad",punc_model="ct-punc",disable_update=True,device="cpu"  # 或 "cuda" 如果有GPU
)    
waveform, _ = sf.read("asr_example.wav")result = model.generate(input=waveform)
print("识别结果:", result[0]["text"])

7.2 运行测试(使用generate)

在这里插入图片描述
第二次运行不会下载模型。
在这里插入图片描述

# 创建虚拟环境
python -m venv sensevoice_env
source sensevoice_env/bin/activate  # Linux/macOS
sensevoice_env\Scripts\activate     # Windows# 安装 SenseVoice 依赖
pip install torch torchaudio numpy

在这里插入图片描述


文章转载自:
http://calves.hfstrb.cn
http://casquette.hfstrb.cn
http://behaviorist.hfstrb.cn
http://canorous.hfstrb.cn
http://aerophile.hfstrb.cn
http://armomancy.hfstrb.cn
http://antifebrin.hfstrb.cn
http://caodaist.hfstrb.cn
http://bissel.hfstrb.cn
http://autoeciously.hfstrb.cn
http://brewer.hfstrb.cn
http://cast.hfstrb.cn
http://chickabiddy.hfstrb.cn
http://angelnoble.hfstrb.cn
http://chloramphenicol.hfstrb.cn
http://alleynian.hfstrb.cn
http://agrypnotic.hfstrb.cn
http://apogeotropically.hfstrb.cn
http://calculably.hfstrb.cn
http://batum.hfstrb.cn
http://astrictive.hfstrb.cn
http://analogism.hfstrb.cn
http://arithmetize.hfstrb.cn
http://auralize.hfstrb.cn
http://bronchial.hfstrb.cn
http://buttonless.hfstrb.cn
http://assuasive.hfstrb.cn
http://adversative.hfstrb.cn
http://antitrades.hfstrb.cn
http://asyllabic.hfstrb.cn
http://www.dtcms.com/a/215802.html

相关文章:

  • Vue3 封装el-table组件
  • 13. CSS定位与伪类/伪元素
  • 从 PyTorch 到 TensorFlow Lite:模型训练与推理
  • 从Node.js到Go:如何从NestJS丝滑切换并爱上Sponge框架
  • jenkins-jenkins简介
  • 微信小程序一次性订阅封装
  • Linux 环境下C、C++、Go语言编译环境搭建秘籍
  • React 第四十七节 Router 中useLinkClickHandler使用详解及开发注意事项案例
  • 【Redis】过期键删除策略,LRU和LFU在redis中的实现,缓存与数据库双写一致性问题,go案例
  • Web安全测试-文件上传绕过-DVWA
  • 人该怎样活着呢?54
  • 【2025最新】Cline自定义API配置完全指南:接入Claude 3.7/GPT-4o
  • Python打卡第38天
  • Python map()函数详解:批量数据处理的瑞士军刀
  • (五)MMA(OpenTelemetry/Rabbit MQ/)
  • Android设置界面层级为最上层实现
  • 零基础远程连接课题组Linux服务器,安装anaconda,配置python环境(换源),在服务器上运行python代码【3/3 适合小白,步骤详细!!!】
  • 深信服防火墙拦截了DELETE、PUT请求,未达到nginx及后端服务
  • 如何将联系人从 Android 传输到 PC(正确步骤)
  • 亚马逊服务器磁盘扩容一般操作
  • R包安装报错解决案例系列|R包使用及ARM架构解决data.table安装错误问题
  • 使用pnpm、vite搭建Phaserjs的开发环境
  • Mico 1.33.1 | 解锁高级版 上千种自定义组件 动态壁纸
  • 评估Facebook的隐私保护:挑战与机遇并存
  • HarmonyOS-ArkUI 窗口层次简介
  • 案例分析|轴承座静力学分析
  • android 输入系统
  • 【R语言编程绘图-折线图】
  • inviteflood:基于 UDP 的 SIP/SDP 洪水攻击工具!全参数详细教程!Kali Linux教程!
  • WPF【09】WPF基础入门 (三层架构与MVC架构)