模型名称: microsoft/VibeVoice-ASR
模型链接: HuggingFace
模型描述: VibeVoice-ASR 是微软发布的统一语音识别大模型,支持长达 60 分钟的音频输入,涵盖 50+ 种语言,并支持说话人分离(speaker diarization)。模型采用统一的 tokenizer + diffusion head 架构,将语音信号通过 acoustic 和 semantic 双 tokenizer 编码后,送入 Qwen2 decoder 进行自回归生成。
模型架构:
输入规格:
输出规格:
| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | >= 2.1.0 | PyTorch 框架(含 torch_npu) |
| torch_npu | >= 2.1.0 | 昇腾 NPU 后端 |
| transformers | >= 4.36.0 | HuggingFace Transformers |
| vibevoice | >= 0.0.1 | VibeVoice 模型实现 |
| sentencepiece | >= 0.1.99 | Tokenizer 依赖 |
| protobuf | >= 3.20.0 | 模型序列化 |
| numpy | < 2 | 数值计算 |
| pillow | >= 9.0 | 图像处理(可选) |
| 昇腾驱动 | CANN 8.0+ | 推荐 CANN 8.5.1 |
安装命令:
# 1. 安装昇腾驱动 (CANN 8.5.1)
# 参考 https://www.hiascend.com/documentation/detail/zh/CANNCommunityEdition/80RC1/osv/pythonpypkg/pythonpypkg_0001.html
# 2. 安装 Python 依赖
pip install torch torch_npu transformers sentencepiece protobuf "numpy<2" pillow
# 3. 安装 VibeVoice 模型代码
pip install git+https://github.com/microsoft/VibeVoice.git# 检查 NPU 设备
npu-smi info
# 验证 torch_npu
python3 -c "import torch_npu; print(torch.npu.device_count(), torch.npu.get_device_name(0))"方式一:HuggingFace(推荐)
huggingface-cli download microsoft/VibeVoice-ASR --local-dir ./VibeVoice-ASR方式二:Python API
python3 -c "from huggingface_hub import snapshot_download; print(snapshot_download('microsoft/VibeVoice-ASR'))"Python 推理脚本(单条/批量推理):
# 单条推理
python3 inference.py \
--model-path ./VibeVoice-ASR \
--audio-duration 5 \
--max-new-tokens 30
# 批量推理
python3 inference.py \
--model-path ./VibeVoice-ASR \
--batch-size 4 \
--audio-duration 10vLLM-Ascend 服务化部署:
vllm serve ./VibeVoice-ASR \
--served-model-name vibevoice \
--trust-remote-code \
--dtype bfloat16 \
--max-model-len 65536 \
--tensor-parallel-size 4 \
--port 8000Python API 调用示例:
import torch
from transformers import AutoConfig
from transformers.models.auto.configuration_auto import CONFIG_MAPPING
from transformers.models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING
from vibevoice.modular.configuration_vibevoice import VibeVoiceConfig
from vibevoice.modular.modeling_vibevoice_asr import VibeVoiceASRForConditionalGeneration
# Register model classes
CONFIG_MAPPING.register("vibevoice", VibeVoiceConfig)
MODEL_FOR_CAUSAL_LM_MAPPING.register(VibeVoiceConfig, VibeVoiceASRForConditionalGeneration)
# Load model
model = VibeVoiceASRForConditionalGeneration.from_pretrained(
"./VibeVoice-ASR", dtype=torch.bfloat16
).to("npu")
# Prepare audio and generate
speech = torch.randn(1, 120000, dtype=torch.bfloat16, device="npu") # 5s @ 24kHz
features = model.encode_speech(speech_tensors=speech)
num_frames = features.shape[1]
input_ids = torch.full((1, num_frames + 10), 1, dtype=torch.long, device="npu")
acoustic_input_mask = torch.zeros(1, num_frames + 10, dtype=torch.bool, device="npu")
acoustic_input_mask[0, :num_frames] = True
outputs = model.generate(
input_ids=input_ids,
speech_semantic_tensors=features,
acoustic_input_mask=acoustic_input_mask,
max_new_tokens=30,
)REST API 调用(vLLM 服务):
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "vibevoice",
"messages": [{"role": "user", "content": "Please transcribe this audio"}],
"audio": {"url": "file:///path/to/audio.wav"}
}'| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model-path | str | 必填 | 模型 checkpoint 路径 |
| --audio-duration | float | 5.0 | 测试音频时长(秒) |
| --max-new-tokens | int | 30 | 最大生成 token 数 |
| --batch-size | int | 1 | 批处理大小 |
| --dtype | str | bfloat16 | 模型精度 (float16/bfloat16/float32) |
| --seed | int | 42 | 随机种子 |
VibeVoice-ASR 的推理 pipeline 与标准 LLM 有所不同:
关键代码:
# 计算语音帧数
sample_rate = 24000
downsampling_ratio = 8 * 5 * 5 * 4 * 2 * 2 # = 3200
num_frames = (sample_rate * audio_duration) // downsampling_ratio
# acoustic_input_mask 控制语音特征插入位置
acoustic_input_mask = torch.zeros(batch, seq_len, dtype=torch.bool)
acoustic_input_mask[:, :num_frames] = True
# 推理
features = model.encode_speech(speech_tensors)
outputs = model.generate(
input_ids=input_ids,
speech_semantic_tensors=features,
acoustic_input_mask=acoustic_input_mask,
max_new_tokens=30,
)[模型] microsoft/VibeVoice-ASR
[设备] Ascend910 (npu:0)
[输入] 随机音频 5s @ 24kHz -> 38 speech frames + 10 text tokens
[输出] logits shape: [1, 48, 152064]
[推理方式] generate(max_new_tokens=30)
[输出] shape: [1, 78] (48 input + 30 generated)
[耗时] Forward: 0.17s, Generate: 0.96s
[状态] SUCCESS[模型] microsoft/VibeVoice-ASR
[设备] Ascend910 (npu:0)
[输入] batch=2, 3s audio each -> 23 frames + 5 text tokens per sample
[输出] logits shape: [2, 28, 152064]
[耗时] Forward: 0.03s
[状态] SUCCESS以上测试使用随机音频输入(torch.randn),生成的文本为随机 token 序列。在实际使用中,需提供真实语音音频文件(需 ffmpeg 支持)以获得有意义的 ASR 输出。模型 pipeline(编码 -> 特征融合 -> 解码 -> 文本生成)完整验证通过。
运行命令:
python3 inference.py --model-path ./VibeVoice-ASR --audio-duration 5输出:
============================================================
VibeVoice-ASR Inference on Ascend NPU
============================================================
Model: ./VibeVoice-ASR
Dtype: bfloat16
Audio duration: 5.0s
Batch size: 1
Max new tokens: 30
============================================================
[1/4] Loading model from ./VibeVoice-ASR ...
Model loaded: 8,674,021,857 parameters, dtype=torch.bfloat16, device=npu
Text tokenizer: VibeVoiceASRTextTokenizerFast
[2/4] Encoding speech (5.0s x 1 batch) ...
Encoded: batch=1, frames=38, dim=3584
Input: seq_len=48, speech_frames=38
acoustic_input_mask: 38 True values
[3/4] Running forward pass ...
Output logits shape: torch.Size([1, 48, 152064])
Forward pass time: 0.17s
[3/4] Running generation (max_new_tokens=30) ...
Output shape: torch.Size([1, 78])
Generated 30 new tokens in 0.96s
Sample 0 decoded: '...'
============================================================
Inference completed successfully
Device: npu:0
Logits shape: torch.Size([1, 48, 152064])
Output shape: torch.Size([1, 78])
============================================================运行命令:
python3 inference.py --model-path ./VibeVoice-ASR --batch-size 2 --audio-duration 3输出:
[2/4] Encoding speech (3.0s x 2 batch) ...
Encoded: batch=2, frames=23, dim=3584
[3/4] Running forward pass ...
Output logits shape: torch.Size([2, 28, 152064])
Forward pass time: 0.03s


评测说明: VibeVoice-ASR 是生成式 ASR 模型,需要真实语音输入进行评测。以下为模型 pipeline 完整性验证结果。
验证项目:
| 验证项 | 结果 | 备注 |
|---|---|---|
| 模型权重加载 | PASS | 8.67B params, bfloat16, 17.3GB |
| Forward pass | PASS | logits [1, 48, 152064], 0.17s on NPU |
| Generate (NPU) | PASS | 30 tokens in 0.96s |
| Batch inference | PASS | batch=2, 0.03s |
| NPU 兼容性 | PASS | 4x Ascend910, torch_npu |
| Operator compatibility | PASS | 全部为标准 PyTorch 算子 |
ASR 精度评测(需真实语音数据):
| 配置项 | 值 |
|---|---|
| NPU 型号 | Ascend910_9362 |
| NPU 数量 | 4 卡 (Chip 0-3) |
| 显存占用 | ~20GB / 64GB per NPU (HBM) |
| 模型精度 | bfloat16 |
| 框架 | torch_npu (PyTorch 2.1+) |
| CANN 版本 | 8.5.1 |
| Tensor Parallel | 未使用(单卡部署) |
| 推理延迟 | ~1s(5s音频 + 30 tokens) |
语音编码需要 NPU: encode_speech() 中的 tokenizer 在 model.to('npu') 后自动移动到 NPU。如果手动分离 CPU/GPU 流程,需确保 tokenizer 与输入 tensor 在同一设备。
acoustic_input_mask 形状: 必须精确匹配 encode_speech 输出的帧数(audio_samples / 3200)。错误形状会导致 RuntimeError: shape mismatch。
generate() 输入: 使用 speech_semantic_tensors(预计算的 combined features)而非 speech_tensors(原始音频),以避免在自回归生成过程中重复编码音频。
文本解码: 模型使用 VibeVoiceASRTextTokenizerFast(底层为 Qwen2Tokenizer),vocab_size=151643(tokenizer)/ 152064(decoder embedding)。
vLLM 集成: 需使用配套的 vLLM v0.18.0+ 插件(vllm_plugin),标准 vLLM 不支持 VibeVoice 的多模态输入格式。