如何下载、安装whisper、faster_whisper?

1、模型种类

whisper:有很多模型:tiny、base、small、medium、large等

faster_whisper:模型种类与whisper类似

2、模型安装

特别注意:whisper和faster_whisper中的模型,有两种获得方式。

①在网址:https://github.com/openai/whisper上有提示:pip install -U openai-whisper,下载结果为 .pt文件。在网址:https://github.com/SYSTRAN/faster-whisper上有提示:pip install faster-whisper,下载结果为.pt文件

②在网址:https://huggingface.co/,进行搜索 whisper,根据提示,可以下载 large-v3和large-v3-turbo,下载结果为文件,与①不同(特别注意)

3.模型运行

①按照①方法下载的模型:运行代码参考网址:https://github.com/openai/whisperhttps://github.com/openai/whisper ,示例如下:

import whisper

model = whisper.load_model("turbo")

load audio and pad/trim it to fit 30 seconds

audio = whisper.load_audio("audio.mp3")

audio = whisper.pad_or_trim(audio)

make log-Mel spectrogram and move to the same device as the model

mel = whisper.log_mel_spectrogram(audio, n_mels=model.dims.n_mels).to(model.device)

detect the spoken language

_, probs = model.detect_language(mel)

print(f"Detected language: {max(probs, key=probs.get)}")

decode the audio

options = whisper.DecodingOptions()

result = whisper.decode(model, mel, options)

print the recognized text

print(result.text)

以上代码,要求# load audio and pad/trim it to fit 30 seconds,提示:whisper模型要求一句话进行识别,如果音频时间太短,可能识别结果不准确,具体请自行尝试。

②按照①方法下载的模型:运行代码参考网址:https://github.com/SYSTRAN/faster-whisperhttps://github.com/SYSTRAN/faster-whisper ,示例如下:

from faster_whisper import WhisperModel

model_size = "large-v3"

Run on GPU with FP16

model = WhisperModel(model_size, device="cuda", compute_type="float16")

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("audio.mp3", beam_size=5)

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

以上代码,model=WhisperModel(...),可以指定cuda编号,以便合理利用资源。

③按照②方法下载的模型,可以参考vllm网址:https://github.com/vllm-project/vllmhttps://github.com/vllm-project/vllm

vllm框架中的whisper模型和faster_whisper模型一定是来自huggingface。

关于vllm安装踩坑问题,以后发布。

相关推荐
abigriver1 天前
打造 Linux 离线大模型级语音输入法:Whisper.cpp + 3090 显卡加速与 Rime 中英混输终极调优指南
linux·运维·whisper
J心流6 天前
89ms实时Whisper,显存还降48%
whisper
iDao技术魔方10 天前
whisper.cpp 深度解析:从边缘设备到实时语音识别
人工智能·whisper·语音识别
Gc9umsbL113 天前
从FLAC到WAV:whisper.cpp中的FFmpeg音频预处理全解析
ffmpeg·whisper·音视频
Bofu-16 天前
【音频测试】03-WPF 实现声道自动验证 + Whisper 语音识别录音检测
c#·whisper·wpf·音视频·音频测试·naudio 声道控制
JK Chen20 天前
faster_whisper,视频转文字,并生成字幕文件
python·whisper·音视频
工作log21 天前
10分钟搭建本地语音识别服务 (Whisper large-v3-turbo)
人工智能·whisper·语音识别
shao91851623 天前
第10章 Streaming(上):初级音频应用(1)——项目三:自建服务器的Mini-Omni实时语音聊天机器人
ffmpeg·whisper·asr·mini-omni·自建语音服务器
code_pgf1 个月前
MNN Whisper 实时 ASR 工程实现
人工智能·whisper·mnn
独占的甜蜜1 个月前
从FLAC到WAV:whisper.cpp中的FFmpeg音频预处理全解析过程
ffmpeg·whisper·音视频