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

1. 资源下载

源码地址

模型下载地址:

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

shell 复制代码
https://github.com/Purfview/whisper-standalone-win/releases/tag/libs

2. 创建环境

conda环境中创建python运行环境

shell 复制代码
conda create -n faster_whisper python=3.9 # python版本要求3.8到3.11

激活虚拟环境

shell 复制代码
conda activate faster_whisper

安装faster-whisper依赖

shell 复制代码
pip install faster-whisper

3. 运行

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

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

说明:

markdown 复制代码
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参数

更多内容欢迎访问博客

对应视频内容欢迎访问视频

相关推荐
可惜已不在14 分钟前
AI 搜索引擎工具集合
人工智能·ai
Landy_Jay17 分钟前
深度学习:基于MindSpore实现CycleGAN壁画修复
人工智能·深度学习
wxin_VXbishe1 小时前
springboot合肥师范学院实习实训管理系统-计算机毕业设计源码31290
java·spring boot·python·spring·servlet·django·php
ITenderL1 小时前
Python学习笔记-函数
python·学习笔记
Langchain1 小时前
不可错过!CMU最新《生成式人工智能大模型》课程:从文本、图像到多模态大模型
人工智能·自然语言处理·langchain·大模型·llm·大语言模型·多模态大模型
zmjia1111 小时前
全流程Python编程、机器学习与深度学习实践技术应用
python·深度学习·机器学习
龙的爹23331 小时前
论文翻译 | Generated Knowledge Prompting for Commonsense Reasoning
人工智能·gpt·机器学习·语言模型·自然语言处理·nlp·prompt
龙的爹23331 小时前
论文翻译 | Model-tuning Via Prompts Makes NLP Models Adversarially Robust
人工智能·gpt·语言模型·自然语言处理·nlp·prompt
方世恩1 小时前
【进阶OpenCV】 (5)--指纹验证
人工智能·opencv·目标检测·计算机视觉
_.Switch2 小时前
Python机器学习:自然语言处理、计算机视觉与强化学习
python·机器学习·计算机视觉·自然语言处理·架构·tensorflow·scikit-learn