Whisper——部署fast-whisper中文语音识别模型

环境配置

bash 复制代码
pip install faster-whisper transformers

准备tiny模型

需要其他版本的可以自己下载:https://huggingface.co/openai

  • 原始中文语音模型:
bash 复制代码
https://huggingface.co/openai/whisper-tiny
  • 微调后的中文语音模型:
bash 复制代码
git clone https://huggingface.co/xmzhu/whisper-tiny-zh
  • 补下一个:tokenizer.json
bash 复制代码
https://huggingface.co/openai/whisper-tiny/resolve/main/tokenizer.json?download=true

模型转换

  • float16
bash 复制代码
ct2-transformers-converter --model whisper-tiny-zh/ --output_dir whisper-tiny-zh-ct2 --copy_files tokenizer.json preprocessor_config.json --quantization float16
  • int8
bash 复制代码
ct2-transformers-converter --model whisper-tiny-zh/ --output_dir whisper-tiny-zh-ct2-int8 --copy_files tokenizer.json preprocessor_config.json --quantization int8

代码

bash 复制代码
from faster_whisper import WhisperModel

# model_size = "whisper-tiny-zh-ct2"
# model_size = "whisper-tiny-zh-ct2-int8"

# Run on GPU with FP16
# model = WhisperModel(model_size, device="cuda", compute_type="float16")
model = WhisperModel(model_size, device="cpu", compute_type="int8")

# 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("output_file.wav", beam_size=5, language='zh')

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))
相关推荐
神州永泰3 分钟前
Java logback框架日志输出中文乱码的解决方案(windows)
java·windows·logback
正在走向自律3 小时前
数字人:打破次元壁,从娱乐舞台迈向教育新课堂(4/10)
人工智能·3d建模·语音识别·娱乐·数字人
Java&Develop5 小时前
redis 免安装版本 启动方法 windows 安装包
数据库·windows·redis
搏博7 小时前
在WPS中通过JavaScript宏(JSA)调用DeepSeek官网API优化文档教程
javascript·人工智能·windows·深度学习·机器学习·wps
hvinsion11 小时前
【Python 开源】你的 Windows 关机助手——PyQt5 版定时关机工具
windows·python·开源·定时关机
陈奕迅本讯11 小时前
操作系统 3.4-段页结合的实际内存管理
windows
简单的心119 小时前
window部署虚拟机VirtualBox来部署flink
大数据·windows·flink
IT _oA21 小时前
Active Directory 域服务
运维·服务器·网络·windows·笔记
yangshuo12811 天前
WSA(Windows Subsystem for Android)安装LSPosed和应用教程
android·windows·模拟器·lsposed·windows安卓子系统
Encarta19931 天前
【语音识别】vLLM 部署 Whisper 语音识别模型指南
人工智能·whisper·语音识别