VibeVoice-Realtime 是一个轻量级实时文本转语音(TTS)模型,支持流式文本输入和稳健的长文本语音生成。它可用于构建实时 TTS 服务、为实时数据流配音,也可让不同 LLM 在完整答案生成之前就「开口说话」。该模型可在约 300 ms 内产出首批可听语音(与硬件相关)。
本仓库是 VibeVoice-Realtime-0.5B 的完整适配代码:内置模型实现(vibevoice 包)、模型配置、实时 TTS 服务(FastAPI + WebSocket)、CLI 推理脚本,并针对 CPU / CUDA / 昇腾 NPU / MPS 做了设备适配。
| 项目 | 内容 |
|---|---|
| 模型名称 | VibeVoice-Realtime-0.5B |
| 模型来源 | HuggingFace |
| 开发方 | Microsoft Research |
| 架构 | VibeVoiceStreamingForConditionalGenerationInference |
| 基础模型 | Qwen/Qwen2.5-0.5B |
| 模型类型 | vibevoice_streaming |
| 参数量 | 0.5B(部署友好) |
| 流水线 | text-to-speech |
| 库 | transformers(需 trust_remote_code / 本仓库内置实现) |
| 采样率 | 24 kHz |
| 上下文长度 | 8k(约 10 分钟音频) |
| 许可证 | MIT |
语言说明:模型主要面向英文;虽然具备一定多语言能力(德/法/意/日/韩/荷/葡/西),但非英语输出可能不可预期,请谨慎使用。
.
├── README.md # 模型卡 + 使用说明(本文件)
├── config.json # 模型配置
├── preprocessor_config.json # 预处理配置
├── vibevoice/ # 模型实现包(modeling / processor / streamer)
├── vibevoice_service.py # 流式 TTS 服务核心(含 NPU 设备适配)
├── server.py # FastAPI + WebSocket 实时服务
├── infer.py # CLI 整段语音合成
├── requirements.txt
├── Dockerfile
├── scripts/
│ ├── download_model.sh # 下载模型权重
│ └── download_voices.sh # 下载音色预设
├── examples/ # 示例文本
├── docs/
│ └── usage.md # 详细使用指南
└── LICENSE # MIT(upstream microsoft/VibeVoice)模型权重(约 1GB)不纳入本仓库,通过
scripts/download_model.sh或直接从 HuggingFace 加载。
pip install -r requirements.txt
# 昇腾 NPU 额外安装:pip install torch-npu (版本需与 torch 匹配)bash scripts/download_model.sh # 模型权重 -> models/VibeVoice-Realtime-0.5B/
bash scripts/download_voices.sh # 音色预设 -> voices/streaming_model/python infer.py --text "Hello, this is a VibeVoice realtime demo." \
--voice en-Carter_man --output output.wav
# 指定昇腾 NPU
python infer.py --text "Hello" --device npu --output output.wavpython server.py --model_path microsoft/VibeVoice-Realtime-0.5B --device autoGET /healthPOST /v1/audio/speech(返回 WAV)WS /stream?text=...&voice=...完整用法见 docs/usage.md。
| 设备 | dtype | attention | 说明 |
|---|---|---|---|
npu | bf16 | sdpa | 昇腾 NPU,需 CANN + torch_npu |
cuda | bf16 | flash_attention_2(失败回退 sdpa) | NVIDIA GPU |
mps | fp32 | sdpa | Apple Silicon |
cpu | fp32 | sdpa | 通用 CPU |
device="auto" 时按 npu > cuda > mps > cpu 自动选择。上游模型仅在 CUDA +
flash_attention_2 上做过完整验证;NPU/CPU/MPS 使用 sdpa,音频质量可能略有差异。
| 模型 | WER (%) ↓ | 说话人相似度 ↑ |
|---|---|---|
| VALL-E 2 | 2.40 | 0.643 |
| Voicebox | 1.90 | 0.662 |
| MELLE | 2.10 | 0.625 |
| VibeVoice-Realtime-0.5B | 2.00 | 0.695 |
本模型仅限研究用途。禁止未经明确同意的声音克隆、深度伪造、误导性内容生成等。 生成内容应披露为 AI 生成,并遵守所在司法辖区的法律法规。详见上游模型卡 HuggingFace。