如何下载、安装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安装踩坑问题,以后发布。

相关推荐
skywalk81631 天前
Windows下安装编译安装Whisper-CPP:一个语音实现框架集和高性能推理模型
人工智能·windows·whisper
linux开发之路2 天前
C++实现Whisper+Kimi端到端AI智能语音助手
c++·人工智能·llm·whisper·openai
吱夏cz8 天前
安装whisper
whisper
Jay星晴9 天前
Whisper-large-v3语音识别效果对比:与Whisper v2/v1在中文长语音场景差异
whisper·语音识别·asr·星图gpu
FishPotatoChen12 天前
【OpenAI】Whisper 模型架构详解
whisper
weixin_4462608513 天前
[特殊字符] Insanely Fast Whisper - 超快音频转录工具!
whisper·音视频
x-cmd14 天前
[260326] x-cmd v0.8.10:跨 Shell 统一配置命令短名;自动装好依赖运行 WhisperLiveKit 实时语音转写
linux·人工智能·ai·whisper·shortcut·x-cmd
ughome24 天前
我做了一个本地字幕提取工具:软字幕优先 + Whisper 转写回退(支持链接/本地文件)
whisper·视频字幕提取
PengShuaiD51 个月前
【AI编码】用ChatGPT基于Whisper+ffmpeg实现一个根据视频字幕执行自动化裁剪本地小工具
人工智能·chatgpt·ffmpeg·whisper
susu10830189112 个月前
OpenAI Whisper 把mp3语音转文字
whisper