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))
相关推荐
光芒再现dev30 分钟前
Win10/Win11文件夹图片不能预览怎么解决?
windows
lingggggaaaa39 分钟前
小迪安全v2023学习笔记(一百四十三讲)—— Win系统权限提升篇&AD内网域控&NetLogon&ADCS&PAC&KDC&CVE漏洞
windows·笔记·学习·安全·内网安全·权限提升
低头不见3 小时前
策略模式上下文管理
windows·python·策略模式
电脑小管家3 小时前
笔记本蓝牙怎么开启 完整教程
windows·驱动开发·计算机外设·电脑·音频
懒羊羊不懒@4 小时前
JavaSe—List集合系列
java·开发语言·数据结构·人工智能·windows
碎像15 小时前
Windows系统暂停强制更新的操作(超详细说明)
windows
周杰伦_Jay1 天前
【网络编程、架构设计与海量数据处理】网络编程是数据流转的血管,架构设计是系统扩展的骨架,海量数据处理是业务增长的基石。
网络·golang·实时互动·云计算·腾讯云·语音识别
专注VB编程开发20年1 天前
Microsoft Speech TTS微软语音识别ISpeechRecoGrammar,ISpeechRecoResult
语音识别·tts·speech·语音朗读
2401_841495641 天前
【语音识别】混合高斯模型
人工智能·python·算法·机器学习·语音识别·gmm·混合高斯模型
Bruce_Liuxiaowei1 天前
SMB签名关闭的安全风险探讨
运维·windows·安全·网络安全