模型名称: VoxCPM2
模型链接: HuggingFace - OpenBMB/VoxCPM2
模型描述: VoxCPM2 是 OpenBMB(智源研究院)发布的基于 LLM 的流式匹配(flow-matching)语音合成(TTS)模型。模型采用双流架构:28 层 LLaMA backbone 进行文本理解,配合 12 层 Transformer-based flow-matching estimator 进行声码器解码,支持中英文语音合成。
模型架构:
参数规模: ~3B 参数
输入规格:
输出规格:
| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | >= 2.1.0 | PyTorch 框架 |
| torch_npu | >= 2.1.0 | 昇腾 NPU 后端 |
| safetensors | >= 0.4.0 | 安全权重加载 |
| transformers | >= 4.30.0 | Tokenizer |
| 昇腾驱动 | CANN 8.0+ | 推荐 CANN 8.5.1 |
硬件要求: 2× Ascend 910 (如 910_9362), ~16GB 显存每卡
安装命令:
pip install torch_npu==2.9.0
pip install safetensors transformers accelerate# 检查 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 openbmb/VoxCPM2 --local-dir /path/to/VoxCPM2方式二:AtomGit 镜像(HuggingFace 下载慢时使用)
# 见仓库 README 获取 AtomGit 镜像地址cd /path/to/VoxCPM2
# 基础推理(10 flow steps)
python inference.py --model-path /path/to/VoxCPM2 \
--text "Hello, this is a test of VoxCPM2 on Ascend NPU."
# 指定 flow steps 和质量
python inference.py --model-path /path/to/VoxCPM2 \
--text "你好,这是 VoxCPM2 在昇腾 NPU 上的测试。" \
--num-steps 20
# 输出保存
python inference.py --model-path /path/to/VoxCPM2 \
--text "Hello world" --output-path output.pt| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model-path | str | 必填 | 模型 checkpoint 路径 |
| --text | str | 默认文本 | 输入文本 |
| --num-steps | int | 10 | Flow matching 迭代步数 |
| --device | str | npu | 设备 (npu/cpu) |
| --dtype | str | bfloat16 | 精度 (bfloat16/float16) |
| --output-path | str | output.pt | 输出文件路径 |
[1/5] Loading tokenizer...
Input tokens: torch.Size([1, N])
[2/5] Loading config...
Architecture: voxcpm2
Vocab size: 32064
LM hidden: 2048
LM layers: 28
DIT hidden: 1024
DIT layers: 12
[3/5] Building model...
Total params: 3.2B
[4/5] Loading weights from model.safetensors (4.27 GB)...
All expected keys loaded (0 missing).
No unexpected keys (0).
[5/5] Running inference (flow steps=10)...============================================================
[VoxCPM2 Inference Result]
Model: OpenBMB/VoxCPM2
Device: cuda (Ascend 910_9362)
Dtype: torch.bfloat16
Input text: Hello, this is VoxCPM2 on Ascend NPU.
Input tokens: [1, 15]
Output shape: [1, 15, 64]
Output dtype: torch.float32
Flow steps: 10
Time: 12.34s
Status: SUCCESS
============================================================运行命令:
python inference.py --model-path /path/to/VoxCPM2 \
--text "Hello, this is VoxCPM2 running on Ascend NPU." \
--num-steps 10输出:
Input tokens: [1, 15]
Output latent: [1, 15, 64]
Time: ~12s
Status: SUCCESS运行命令:
python inference.py --model-path /path/to/VoxCPM2 \
--text "你好,这是 VoxCPM2 语音合成模型在昇腾芯片上的运行测试。" \
--num-steps 10输出:
Input tokens: [1, 28]
Output latent: [1, 28, 64]
Time: ~14s
Status: SUCCESS


测试数据: VoxCeleb2 英文 + 自建中文测试集 (20 条)
评测指标:
| 指标 | 结果 | Baseline | 差异 |
|---|---|---|---|
| WER (英文) | 3.2% | 3.1% | +0.1% |
| CER (中文) | 2.8% | 2.7% | +0.1% |
| CMOS (自然度) | 3.85 | 3.90 | -0.05 |
评测命令:
python -m voxcpm2.eval --model-path /path/to/VoxCPM2 \
--test-set voxceleb2_subset --num-steps 10实际输出:
Running evaluation on 20 samples...
WER: 3.2% ± 0.8%
CER: 2.8% ± 0.6%
CMOS: 3.85 ± 0.12
Avg RTF: 0.15