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

环境配置

pip install faster-whisper transformers

准备tiny模型

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

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

模型转换

  • float16
ct2-transformers-converter --model whisper-tiny-zh/ --output_dir whisper-tiny-zh-ct2 --copy_files tokenizer.json preprocessor_config.json --quantization float16
  • int8
ct2-transformers-converter --model whisper-tiny-zh/ --output_dir whisper-tiny-zh-ct2-int8 --copy_files tokenizer.json preprocessor_config.json --quantization int8

代码

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))

相关推荐

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

    2024-01-13 06:12:05       61 阅读
  2. 开源语音识别faster-whisper部署教程

    2024-01-13 06:12:05       67 阅读
  3. 本地部署whisper模型语音转文字)

    2024-01-13 06:12:05       57 阅读
  4. [语音识别]开源语音识别faster-whisper模型下载地址

    2024-01-13 06:12:05       59 阅读
  5. Android 手机部署whisper 模型

    2024-01-13 06:12:05       31 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-13 06:12:05       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-13 06:12:05       100 阅读
  3. 在Django里面运行非项目文件

    2024-01-13 06:12:05       82 阅读
  4. Python语言-面向对象

    2024-01-13 06:12:05       91 阅读

热门阅读

  1. 19. 蒙特卡洛强化学习之策略控制

    2024-01-13 06:12:05       58 阅读
  2. 商务外语MR混合现实仿真情景实训教学

    2024-01-13 06:12:05       66 阅读
  3. 机器学习之集成学习概念介绍

    2024-01-13 06:12:05       56 阅读
  4. sqlite3 jdbc 只读模式

    2024-01-13 06:12:05       62 阅读
  5. c#两个数进行交换

    2024-01-13 06:12:05       61 阅读