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))
相关推荐
智慧景区与市集主理人12 小时前
巨有科技景区智能导览告别传统讲解,打造沉浸式智慧游览体验
人工智能·科技·语音识别
三无推导15 小时前
ComfyUI 安装部署教程:Windows 下快速搭建可视化 AI 绘图工作流,零基础也能跑通
人工智能·pytorch·windows·stable diffusion·aigc·ai绘画·持续部署
feifeigo12317 小时前
基于隐马尔可夫模型(HMM)的孤立词语音识别系统
人工智能·语音识别·xcode
2601_9583529017 小时前
AP-0316 语音模块实测效果与能力边界展示
语音识别·硬件开发·ai降噪·音频处理模块
nnsix17 小时前
PS【PhotoShop】实现拷贝到Windows粘贴板上
windows
сокол17 小时前
【网安-Web渗透测试-免杀系列】内存免杀(无文件落地)
windows·网络安全
玖釉-17 小时前
二叉树基础详解:TreeNode、buildTree、deleteTree 与 printTree 的实现原理(C++)
c++·windows·算法
心之所向,自强不息17 小时前
# Unity MCP + Codex CLI 完整教程(Windows)
windows·unity·游戏引擎
特立独行的猫a18 小时前
Fast DDS Monitor Windows x64 从源码编译安装完全教程
windows·monitor·dds·fastdds·fastddsmonitor
慵懒的猫mi19 小时前
deepin 25部署x11vnc+xrdp,实现vnc和mstsc双重访问
linux·windows·开源软件·deepin