当前位置: 代码网 > 服务器>软件设计>开源 > 开源语音识别faster-whisper部署教程

开源语音识别faster-whisper部署教程

2024年08月01日 开源 我要评论
开源语音识别项目faster-whisper的部署详细过程,本篇文章简洁明了阐述了faster-whisper的部署过程。

1. 资源下载

源码地址

模型下载地址:

large-v3模型:https://huggingface.co/systran/faster-whisper-large-v3/tree/main
large-v2模型:https://huggingface.co/guillaumekln/faster-whisper-large-v2/tree/main
large-v2模型:https://huggingface.co/guillaumekln/faster-whisper-large-v1/tree/main
medium模型:https://huggingface.co/guillaumekln/faster-whisper-medium/tree/main
small模型:https://huggingface.co/guillaumekln/faster-whisper-small/tree/main
base模型:https://huggingface.co/guillaumekln/faster-whisper-base/tree/main
tiny模型:https://huggingface.co/guillaumekln/faster-whisper-tiny/tree/main

下载cublas and cudnn

https://github.com/purfview/whisper-standalone-win/releases/tag/libs

2. 创建环境

conda环境中创建python运行环境

conda create -n faster_whisper python=3.9 # python版本要求3.8到3.11

激活虚拟环境

conda activate faster_whisper

安装faster-whisper依赖

pip install faster-whisper

3. 运行

执行完以上步骤后,我们可以写代码了

from faster_whisper import whispermodel

model_size = "large-v3"

path = r"d:\works\python\faster_whisper\model\small"

# run on gpu with fp16
model = whispermodel(model_size_or_path=path, device="cuda", local_files_only=true)

# or run on gpu with int8
# model = whispermodel(model_size, device="cuda", compute_type="int8_float16")
# or run on cpu with int8
# model = whispermodel(model_size, device="cpu", compute_type="int8")

segments, info = model.transcribe("c:\\users\\21316\\documents\\录音\\test.wav", beam_size=5, language="zh", vad_filter=true, vad_parameters=dict(min_silence_duration_ms=1000))

print("detected language '%s' with probability %f" % (info.language, info.language_probability))

for segment in segments:
    print("[%.2fs -> %.2fs] %s" % (segment.start, segment.end, segment.text))

说明:

local_files_only=true 表示加载本地模型
model_size_or_path=path 指定加载模型路径
device="cuda" 指定使用cuda
compute_type="int8_float16" 量化为8位
language="zh" 指定音频语言
vad_filter=true 开启vad
vad_parameters=dict(min_silence_duration_ms=1000) 设置vad参数

更多内容欢迎访问博客
对应视频内容欢迎访问视频

(0)

相关文章:

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

发表评论

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