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

相关推荐
MindUp11 天前
多款AI语音转写+LLM复盘方案横评:从Whisper本地部署到网盘智能体全链路实测
人工智能·whisper
Niuguangshuo13 天前
ASR 五代演进(五):Gen 4 · 以 Whisper 为代表的大规模弱监督
whisper
Generalzy19 天前
Whisper + VAD + TTS:一套完整的 Python 本地语音处理流水线
python·whisper·语音识别
shxjnpl20 天前
Whisper + CAM++ + 本地大模型:一套完全离线的AI会议处理链路
人工智能·机器学习·whisper
shxjnpl20 天前
Whisper large-v3 本地部署实战:从语音转写到AI会议纪要完整链路
人工智能·whisper·语音识别
程序猿编码20 天前
不用PyTorch,不用CUDA,我用C++手写了一个能跑GPT和Whisper的推理库
c++·pytorch·gpt·大模型·whisper
今夕资源网1 个月前
今夕语音中枢一键整合包:本地 LuxTTS 发声 + Whisper 听觉 + AIRI一键接入听觉和发声模块
whisper·ai伴侣·airi·ai女友·ai宠物
大鱼>1 个月前
Whisper+GPT-SoVITS:语音识别到音色克隆的全链路实战
gpt·whisper·语音识别
维基框架2 个月前
Apple的SpeechAnalyzer API实测:系统级语音识别与Whisper的差距在哪里
人工智能·whisper·语音识别·xcode
向阳是我2 个月前
在 Mac(M2)上用 faster-whisper 实现高精度中文语音转文字
python·macos·ai·whisper·语音识别