VibeVoice-ASR 是微软发布的统一语音识别模型,专为处理 60分钟长音频 而设计,支持单次推理完成自动语音识别、说话人分离和时间戳标注。支持 50+ 语言 和 自定义热词。
| 组件 | 配置 |
|---|---|
| 解码器 (LLM) | Qwen2-based, 28层, hidden=3584, 28注意力头 (GQA 4 KV heads) |
| 声学 Tokenizer | VAE, vae_dim=64, depthwise conv |
| 语义 Tokenizer | VAE, vae_dim=128, depthwise conv |
| 词表大小 | 152,064 |
| 最大位置 | 131,072 tokens (64K 语音 token) |
| 模型大小 | ~17GB (8 shards, safetensors) |
| 项目 | 要求 |
|---|---|
| NPU 芯片 | Ascend910 / Ascend910_9362 |
| NPU 数量 | 1-2 颗 (单卡即可运行) |
| HBM 内存 | ≥ 6 GB (模型占用 ~3GB) |
| 系统内存 | ≥ 16 GB (加载模型权重) |
| 驱动 | CANN 8.5.1+ |
| torch_npu | 2.9.0+ |
# Ubuntu / CentOS
# 确保已安装 CANN Toolkit 和 torch_npu
# 参考: https://www.hiascend.com/document/detail/zh/Pytorch/700/indexpip install transformers>=4.37.0
pip install torch_npu>=2.9.0
pip install librosa>=0.10.0
pip install soundfile>=0.12.0
pip install huggingface_hub>=0.20.0
pip install diffusers>=0.25.0
pip install accelerate>=0.25.0
pip install numpy>=1.24.0或使用 requirements.txt:
pip install -r requirements.txtgit clone https://gitcode.com/<username>/VibeVoice-ASR.git
cd VibeVoice-ASR模型权重 ~17GB,需单独下载:
python3 -c "
import os
os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'
from huggingface_hub import snapshot_download
snapshot_download(
'microsoft/VibeVoice-ASR',
local_dir='./model/microsoft/VibeVoice-ASR',
)
"脚本会自动下载 Qwen2.5-7B Tokenizer 到 Qwen2.5-7B-tokenizer/ 目录。
export PYTHONPATH=/path/to/VibeVoice:$PYTHONPATH
python3 inference.py \
--model_path ./model/microsoft/VibeVoice-ASR \
--audio your_audio.wav \
--device npu \
--max_new_tokens 32768python3 inference.py \
--model_path ./model/microsoft/VibeVoice-ASR \
--audio-dir ./audio_files/ \
--device npu \
--batch_size 4python3 inference.py \
--model_path ./model/microsoft/VibeVoice-ASR \
--device npu \
--benchmark \
--benchmark-runs 10 \
--warmuppython3 inference.py \
--model_path ./model/microsoft/VibeVoice-ASR \
--audio meeting.wav \
--device npu \
--hotwords "Microsoft,VibeVoice,GPT"| 引擎 | 状态 | 说明 |
|---|---|---|
| torch_npu | ✅ 推荐 | 原生 PyTorch 算子,直接映射到 NPU 指令 |
| vLLM-Ascend | ❌ 不适用 | vLLM 仅支持 LLM (decoder-only/encoder-decoder),VibeVoice 使用自定义 VAE tokenizer + LLM 混合架构 |
| SGLang | ❌ 不适用 | 同 vLLM,仅支持标准 LLM 架构 |
为什么不使用 vLLM?
VibeVoice-ASR 的前向传播包含自定义的 VAE tokenizer(acoustic + semantic)和 speech connector,这些组件在 encode_speech() 方法中动态执行,无法被 vLLM 的模型执行器管理。因此使用原生 torch_npu + transformers 是最可靠的方案。
在适配过程中发现并修复了以下 NPU 兼容性问题:
aclnnIndexPutImpl dtype mismatch现象:
RuntimeError: _index_put_impl_ NPU function error: call aclnnIndexPutImpl failed
AclNN_Parameter_Error(EZ1001): Tensor selfRef expected dtype is DT_FLOAT16 but found DT_FLOAT原因:modeling_vibevoice_asr.py 的 forward() 方法中,inputs_embeds(模型嵌入层输出,bfloat16)与 speech_features(tokenizer 输出,float32)dtype 不一致。NPU 的 index_put 操作要求 tensor dtype 完全匹配。
修复(modeling_vibevoice_asr.py 第 382 行):
# 添加 dtype 转换
speech_features = speech_features.to(dtype=inputs_embeds.dtype)
inputs_embeds[acoustic_input_mask] = speech_featurespython3 inference.py \
--model_path ./model/microsoft/VibeVoice-ASR \
--audio test_audio.wav \
--device npu \
--max_new_tokens 128输出:
--- Result #1 ---
Time: 1.61s
Input tokens: 82
Output tokens: 29
Segments: 1
[0 - 3.0] Speaker 0: [Music][BENCH] Results (5 runs):
Mean: 1.645s ± 0.494s
Min: 1.383s, Max: 2.633s[WARMUP] Warmup complete, 3 iterations in 6.05s
[INFER] Found 1 audio file(s)
--- Result #1 ---
Time: 1.61s[LOAD] Loading model from ./model/microsoft/VibeVoice-ASR
[LOAD] Device: npu, dtype: torch.float32, attention: sdpa
[LOAD] Loading complete, took 26.80s使用合成音频(正弦波)测试模型基本功能。由于模型输出为结构化 JSON(包含说话人、时间戳、内容),验证输出格式正确性。
| 测试项 | 结果 |
|---|---|
| 输入音频 | 3秒 440Hz 正弦波 (合成音频) |
| 输出格式 | 结构化 JSON |
| 内容识别 | [Music] |
| 说话人标注 | Speaker 0 |
| 时间戳 | [0 - 3.0] |
注:由于缺少真实语音数据集(如 LibriSpeech),当前使用合成音频验证模型在 NPU 上的完整推理流程。模型在真实语音上的 WER/cpWER/tcpWER 指标请参考 原论文。
VibeVoice-ASR/
├── inference.py # NPU 推理脚本 (主入口)
├── README.md # 部署文档 (本文件)
├── requirements.txt # Python 依赖
├── verification_outputs.txt # 验证报告
├── .gitignore # Git 忽略规则
├── model/
│ └── microsoft/
│ └── VibeVoice-ASR/ # 模型权重 (需单独下载)
│ ├── config.json
│ ├── model-00001-of-00008.safetensors
│ ├── ... (8 shards)
│ └── preprocessor_config.json
├── Qwen2.5-7B-tokenizer/ # 本地 tokenizer (自动下载)
└── assets/
├── agent_workflow.png
├── npu_device_call.png
├── model_result.png
├── adapt_agent_precheck.png
└── verify_agent_npu.pngModuleNotFoundError: No module named 'vibevoice'确保 PYTHONPATH 包含 VibeVoice 源码路径:
export PYTHONPATH=/path/to/VibeVoice:$PYTHONPATHaclnnIndexPutImpl failed这是 NPU dtype 不匹配错误。确保使用本仓库修改后的 modeling_vibevoice_asr.py,包含 speech_features.to(dtype=inputs_embeds.dtype) 修复。
RuntimeError: NPU out of memory--max_new_tokens(默认 32768,建议测试时用 128-512)dtype=torch.float32(而非 bfloat16,后者在某些 NPU 算子中可能导致额外内存开销)Could not load preprocessor_config.json确保 preprocessor_config.json 存在于模型目录中,且 language_model_pretrained_name 指向正确的 tokenizer 路径。
17GB 模型首次加载需要 20-30 秒(取决于存储速度)。后续推理会快很多。使用 --warmup 可以进一步稳定首次推理性能。
[Music] 而不是文本这是正常的——输入是合成音频(正弦波),模型正确识别为非语音内容。使用真实语音文件会得到文本转录结果。
This project is licensed under the MIT License - see the LICENSE file for details.