超快速Whisper MCP服务器
利用OpenAI的Whisper技术,并结合Hugging Face Transformers和Flash Attention 2的优化,打造极速音频转录MCP服务器。
⚡️(闪电符号,常用于表示快速、能量或电力等概念,在中文中可直接用该符号表示,或根据上下文翻译为“闪电”、“快速”等) 在不到98秒的时间内转录150分钟(2.5小时)的音频!
特点/特性
- 🚀 表情符号“🚀”通常被翻译为“火箭”或“飞速前进”,在中文中常用来表示快速、迅速或激动人心的事物。所以,这个表情可以简单地翻译为“火箭”或根据语境翻译为“飞速前进”等。 超快速转录 使用优化后的Whisper模型
- 🎯(目标、靶心) 多种转录工具 对于文件、URL和日记化(或时间戳划分)
- 🔧(扳手,表示修理、工具等意思) 可配置模型 从tiny到large-v3,包括蒸馏版本
- 💬 说话人日志(或说话人识别与分割) 与Pyannote.audio集成
- ⚡(闪电符号,常用于表示速度、活力或电力等概念,在此无具体上下文时可直接保留原样或根据具体语境翻译为“闪电”) Flash Attention 2 支持更快的处理速度
- 🌍 代表地球。 多语言 支持自动语言检测
- 📝 单词或片段级别的时间戳 为了精确计时
- 🎨 表示“艺术创作”或“绘画”的意思。 翻译 将音频翻译成英文的模式
安装
先决条件
- Python 版本大于等于 3.10
- 紫外线 包管理器
- NVIDIA GPU(推荐)或Apple Silicon Mac
- CUDA工具包(适用于NVIDIA GPU)或MPS支持(适用于Mac)
从源代码安装
# Clone the repository
git clone
cd insanely-fast-whisper-mcp
# Install dependencies
uv sync
# Install insanely-fast-whisper CLI (required)
uv pip install insanely-fast-whisper可选:安装Flash Attention 2
为了达到最高速度,请安装Flash Attention 2:
uv pip install flash-attn --no-build-isolation用法
本地开发
# Start the server in development mode
uv run dev在铁匠铺操场进行测试
# Port-forward to Smithery Playground via ngrok
uv run playground配置
服务器接受会话特定的配置以定制转录行为:
{
"model_name": "openai/whisper-large-v3",
"device_id": "0",
"batch_size": 24,
"flash": false,
"task": "transcribe",
"language": null,
"timestamp": "chunk",
"hf_token": null,
"num_speakers": null,
"min_speakers": null,
"max_speakers": null
}配置选项
| 选项 | 类型 | 默认值 | 描述 | |||
|---|---|---|---|---|---|---|
| (无对应中文翻译,原为表格分隔线) | (无对应中文翻译,原为表格分隔线) | (无对应中文翻译,原为表格分隔线) | (无对应中文翻译,原为表格分隔线) | model_name | openai/whisper-large-v3 | 字符串 |
| 要使用的Whisper模型 | device_id | "0" | 字符串 | |||
| GPU 设备 ID 或 Mac 上的 "mps" | batch_size | 24 | 整数 | |||
| 并行批次数量 | flash | false | 布尔型 | |||
| 使用 Flash Attention 2 | task | "transcribe" | 字符串 | |||
“转录”或“翻译” language | null | 字符串 | ||||
| 语言代码(例如,“en”、“es”)或设为null以自动检测 | timestamp | "chunk" | 字符串 | |||
“块”或“词”级别的时间戳 hf_token | null | 字符串 | ||||
用于说话人识别的Hugging Face令牌 num_speakers | null | 整数 | ||||
| 演讲者的确切人数 | min_speakers | null | 整数 | |||
| 最少发言人数 | max_speakers | null | 整数 |
| 最大扬声器数量 |
可用工具
1\. 转录文件
Args:
file_path (string): Path to the audio file
output_path (string, optional): Path to save transcript JSON
Returns:
Dictionary with transcription text and timestamps转录本地音频文件。
2\. 转录URL
Args:
url (string): URL of the audio file
output_path (string, optional): Path to save transcript JSON
Returns:
Dictionary with transcription text and timestamps从URL转录音频文件。
3\. 带说话人识别的转录
Args:
file_path (string): Path to the audio file
num_speakers (integer, optional): Exact number of speakers
min_speakers (integer, optional): Minimum number of speakers
max_speakers (integer, optional): Maximum number of speakers
output_path (string, optional): Path to save transcript JSON
Returns:
Dictionary with transcription and speaker labels使用说话人识别进行转录(需要Hugging Face令牌)。
4\. 获取支持的模型
Returns:
Dictionary with model information获取可用的Whisper模型列表及其特性。
示例用法
Please transcribe the audio file at /path/to/recording.mp3转录本地文件:
Transcribe this podcast episode: https://example.com/podcast.mp3从URL转录:
Transcribe /path/to/meeting.wav and identify the 3 speakers进行带说话人区分的转录:
Use distil-whisper/large-v2 to transcribe /path/to/audio.mp3使用更快的模型:
Translate this Spanish audio to English: /path/to/spanish.mp3翻译成英文:
支持的模型 | 模型 | 速度 | 准确率 | 大小 | 推荐 | |-------|-------|----------|------|-------------| openai/whisper-large-v3 | | 快速\* | 最高 | 约3GB | ✅ 是 | distil-whisper/large-v2 | | 速度提升2倍\* | 非常高 | ~3GB | ✅ 是 | openai/whisper-large-v2 | | 快速\* | 非常高 | ~3GB | | openai/whisper-medium | | 非常快速 | 高 | ~1.5GB | | openai/whisper-small | | 极速 | 中等 | ~500MB | | openai/whisper-base |
| 极速 | 低 | ~150MB | |
\* 配备Flash Attention 2和优化技术
部署
- 部署到Smithery
- 创建一个GitHub仓库
- 推送你的代码 首选
- Smithery 翻译成中文可以是“铁匠铺”或“锻造工坊”
点击“部署”并选择您的存储库
# Build Docker image
docker build -t insanely-fast-whisper-mcp .
# Run container
docker run -p 8000:8000 insanely-fast-whisper-mcpDocker 部署
演出
NVIDIA A100 - 80GB 的基准测试:
| 配置 | 时间(150分钟音频) | 速度提升 | |||||||
|---|---|---|---|---|---|---|---|---|---|
| (标题或分类) | (具体内容或描述) | (其他信息) | |||||||
| large-v3(fp32,默认) | 约31分钟 | 1倍 | ** | large-v3(fp16 + 批处理) | 约5分钟 | 6倍 | ** | large-v3(fp16 + Flash Attention 2) | 约1.6分钟 |
| 19x ** | ** | distil-large-v2(fp16 + Flash Attention 2) | 约1.3分钟 |
24倍
|
常见问题解答(FAQ) "flash": true 如何启用 Flash Attention 2?
uv pip install flash-attn --no-build-isolation设定
- 在您的会话配置中。确保已安装flash-attn: 我如何使用说话人日志技术?
- 从(某处)获取一个Hugging Face令牌 hf.co/settings/tokens 翻译为中文是:“hf.co 设置/令牌”
- 接受Pyannote.audio的条款于
"hf_token": "hf_xxx" - pyannote/说话人分离(或:说话人日记化)
transcribe_with_diarization将您的令牌添加到会话配置中:
使用
工具
支持哪些音频格式?
FFmpeg支持的任何格式:MP3、WAV、M4A、FLAC、OGG、AAC、WMA 等。 batch_size 如何减少内存使用?
降低
在你的配置中(默认值:24)。如果遇到内存不足(OOM)错误,请尝试设置为16、12、8或4。 "device_id": "mps" 我可以在Mac上运行这个吗?
是的!设定好
在你的配置中。注意:MPS(金丝雀优化器,此处根据上下文推测,实际可能指某种特定的处理器或优化技术,但MPS通常有多种含义,需根据具体语境判断)的优化程度不如CUDA,因此建议使用较小的批量大小(4-8)。
故障排除 batch_size 内存不足(OOM)错误
- 减少
- 在你的配置中:
- NVIDIA GPU:尝试使用16、12或8(此处可能指线程数、分辨率或其他相关参数)
Mac(MPS):尝试4次
更小的GPU:尝试使用4个或更少
uv pip install flash-attn --no-build-isolationFlash Attention 2 安装失败
确保已安装CUDA工具包,并使用:
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121“Torch 未编译启用 CUDA 版本”(在 Windows 上)
- 手动安装带有CUDA支持的PyTorch: 致谢/鸣谢
- “Insanely Fast Whisper”可以翻译为“超快低语”或“极速耳语”,具体翻译取决于语境和想要传达的细微差别。在这里,“Insanely Fast”强调速度极快,超乎寻常;“Whisper”则指的是低声说话或传达信息。因此,整个短语可以理解为一种以极快速度进行的低语或信息传递 - 原始CLI工具
- OpenAI Whisper(奥普尼·惠斯特) - 基础模型
- Hugging Face Transformers(哈ugging Face转换器) - 优化
- Flash Attention 2 - 速度提升
Smithery.ai(直接翻译为中文即“史密斯里人工智能”,但具体翻译可能需根据品牌或公司的实际中文名调整,此处为直译)
\- MCP(可能指某种特定系统或服务,如“管理控制平台”等,具体根据上下文确定)部署平台
许可证
Apache 2.0
