GitHub – Vaibhavs10/insanely-fast-whisper

2个月前发布 9 00

Contribute to Vaibhavs10/insanely-fast-whisper development by creating an account on GitHub.

收录时间:
2025-10-06
GitHub – Vaibhavs10/insanely-fast-whisperGitHub – Vaibhavs10/insanely-fast-whisper

网站整体介绍
这是GitHub上一个名为“Insanely Fast Whisper”的开源项目页面,核心是一款基于OpenAI Whisper模型的命令行(CLI)音频转录工具,主打“极致快速”的本地音频转文字能力。项目依托🤗Hugging Face的Transformers、Optimum框架,结合Flash Attention 2等优化技术,大幅提升Whisper模型的转录速度,同时支持CUDA(NVIDIA GPU)和MPS(苹果 Silicon 芯片)设备。

核心功能与特色
1. 超高速转录能力
项目提供了详细的性能基准测试(基于NVIDIA A10080GB GPU):
未优化的Whisper largev3(fp32)转录150分钟音频需约31分钟;
开启`fp16`+`批量处理(24)`+`Flash Attention 2`后,仅需1分38秒(速度提升约19倍);
若使用distilwhisper/largev2模型+Flash Attention 2,甚至能压缩到1分18秒。

2. 便捷的CLI工具
提供高度封装的命令行接口,支持从本地文件或URL读取音频,无需复杂代码。例如:
基础转录:`insanelyfastwhisper filename `;
开启Flash Attention 2:`insanelyfastwhisper filename flash True`;
使用蒸馏模型:`insanelyfastwhisper modelname distilwhisper/largev2 filename `。
同时支持`deviceid`(指定GPU设备,Mac需设为`mps`)、`batchsize`(调整批量大小避免OOM)、`timestamp`(选择“段落”或“单词”级时间戳)等参数。

3. 多设备支持
兼容NVIDIA CUDA GPU(Windows/Linux)和苹果MPS设备(macOS),但需注意:
Mac用户需添加`deviceid mps` flag,并降低`batchsize`(如设为4,避免内存不足);
Windows用户若遇“CUDA未编译”错误,需手动安装对应版本的PyTorch(如`cu121`)。

安装与使用说明
1. 安装方式
推荐用`pipx`(隔离环境,避免依赖冲突):
`pipx install insanelyfastwhisper==0.0.15 force`(若Python 3.11+需加`ignorerequirespython`);
临时使用(无需安装):`pipx run insanelyfastwhisper filename `。

2. Flash Attention 2安装
若需开启Flash Attention 2优化,需额外执行:
`pipx runpip insanelyfastwhisper install flashattn nobuildisolation`。

非CLI使用方式
若不想用命令行,也可通过Python代码直接调用模型:
1. 安装依赖:`pip install upgrade transformers optimum accelerate`;
2. 运行以下代码(需替换“为音频路径):
“`python
import torch
from transformers import pipeline
from transformers.utils import is_flash_attn_2_available

pipe = pipeline(
“automaticspeechrecognition”,
model=”openai/whisperlargev3″,
torch_dtype=torch.float16,
device=”cuda:0″, 或”mps”(Mac)
model_kwargs={“attn_implementation”: “flash_attention_2”} if is_flash_attn_2_available() else {}
)

outputs = pipe(“”, chunk_length_s=30, batch_size=24, return_timestamps=True)
print(outputs)
“`

常见问题解决
Mac内存不足(OOM):降低`batchsize`至4(约占12GB VRAM),并确保设`deviceid mps`;
Windows CUDA错误:手动安装PyTorch(如`python m pip install torch indexurl https://download.pytorch.org/whl/cu121`);
Flash Attention 2安装失败:使用`nobuildisolation`参数重新安装。

社区与扩展
项目是社区驱动的开源工具,页面还展示了社区衍生的应用案例:
第三方CLI工具(如ochen1/insanelyfastwhispercli);
NextJS+Modal搭建的网页应用(arihanv/Shush);
基于Transformers的Python封装库(kadirnar/whisperplus)。

相关导航

没有相关内容!

暂无评论

您必须登录才能参与评论!
立即登录
none
暂无评论...