赞
踩
- whisper:https://github.com/openai/whisper/tree/main
参考文章:Whisper OpenAI开源语音识别模型
pip install faster-whisper transformers
需要其他版本的可以自己下载: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))
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。