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))
相关推荐
小白白3619 小时前
Pixelorama怎么用?像素画绘制和动画制作入门
windows
sukalot12 小时前
windows网络适配器驱动开发-WiFiCx Wi-Fi 7 功能要求(三)
windows·驱动开发
浪潮BB机14 小时前
2026腾讯会议随身鹿等五大项目交接录音工具实测横评
语音识别·效率工具·腾讯会议·ai工具·录音转写·会议纪要
脚踏实地皮皮晨14 小时前
003003001_Grid控件
开发语言·windows·算法·c#·visual studio
ziguo112215 小时前
Windows API MessageBox 函数详解
c语言·c++·windows·visualstudio
sukalot16 小时前
windows网络适配器驱动开发-WiFiCx Wi-Fi 7 功能要求(二)
windows·驱动开发
RTC实战笔记17 小时前
IM 产品怎么加语音房?从消息系统到麦位、房间和实时互动
实时互动·语音识别·实时音视频
声讯电子18 小时前
实测A-59F音频模组:降噪稳、不啸叫、通话清晰
人工智能·语音识别·ai降噪·usb接口·回音消除
山河不见老18 小时前
【Cursor 、Qoder安装问题】Cursor 、Qoder安装卡在“正在准备安装”问题排查及解决
人工智能·windows·编辑器
love530love19 小时前
Windows 原生编译 SGLang(2/8):三铁证判定可行 + --no-deps 外科手术式安装
windows·sglang