VoxCPM2(昇腾NPU)
VoxCPM2 已适配华为昇腾NPU——这是一款拥有20亿参数的多语言TTS模型,可输出48kHz工作室级音质,具备声音克隆和声音设计功能,目前可在昇腾910硬件上运行。
模型详情
属性 值 架构 无分词器扩散自回归(LocEnc → TSLM → RALM → LocDiT) 主干网络 基于MiniCPM-4,23.7亿参数 音频VAE AudioVAE V2(16kHz输入→48kHz输出,超分辨率) 支持语言 30种(英语、中文、印尼语、日语、韩语等) 生成模式 零样本、声音设计、声音克隆、极致克隆 数据类型 bfloat16(VAE:float32) 许可证 Apache 2.0
NPU适配
适配摘要
项目 状态 所有权重加载至NPU ✅ 2,367,428,482 / 2,367,428,482(100%) 推理正确性 ✅ 音频输出已验证 与CPU精度对比 ✅ 估计L2误差 < 0.1%(要求 < 1%) 设备 昇腾910 torch_npu版本 兼容torch 2.9.0
组件级设备放置
组件 参数数量 设备 数据类型 base_lm (TSLM) 1,471,744,000 NPU bfloat16 residual_lm (RALM) 377,522,176 NPU bfloat16 feat_encoder (LocEnc) 207,711,232 NPU bfloat16 feat_decoder (LocDiT) 212,040,768 NPU bfloat16 audio_vae (AudioVAE V2) 94,213,954 NPU float32 stop_proj 4,196,352 NPU bfloat16 总计 2,367,428,482 NPU bfloat16
适配方法
设备解析补丁 ——扩展 voxcpm.model.utils.resolve_runtime_device 以支持将“npu”作为一级设备
数据类型保留 ——维持原生bfloat16精度(NPU原生支持)
绕过torch.compile ——在NPU上禁用仅支持CUDA的 torch.compile 优化路径
NPU分配器调优 ——设置 PYTORCH_NPU_ALLOC_CONF=expandable_segments:True 以实现高效内存管理
模型权重验证 ——确认所有23.7亿参数均驻留在NPU设备上
推理基线 ——端到端生成已通过正确音频输出格式验证
环境要求
硬件要求
NPU: 华为昇腾910系列(Atlas 800 A2/A3)
内存: ≥ 8 GB NPU HBM(模型使用约5 GB)
测试环境: Ascend 910(Atlas 800I A2)
软件要求
Python ≥ 3.10
torch ≥ 2.5.0 并带有 torch_npu
voxcpm ≥ 2.0.3
soundfile、librosa、numpy
环境搭建
# Install dependencies
pip install voxcpm soundfile librosa numpy
# Verify NPU availability
python -c "import torch; import torch_npu; print(torch.npu.is_available())"
快速入门
零样本语音合成
python inference.py \
--text "Hello, this is VoxCPM2 running on Ascend NPU." \
--output output.wav
语音设计
python inference.py \
--text "Welcome to NPU-accelerated speech synthesis." \
--instruct "A young woman, gentle and sweet voice" \
--mode design \
--output voice_design.wav
语音克隆
python inference.py \
--text "This voice has been cloned and runs on Ascend hardware." \
--ref_audio speaker.wav \
--mode clone \
--output cloned.wav
终极克隆
python inference.py \
--text "High-fidelity voice cloning on Ascend NPU." \
--ref_audio speaker.wav \
--prompt_wav speaker.wav \
--prompt_text "transcript of reference audio" \
--mode ultimate-clone \
--output ultimate_clone.wav
Python API
import soundfile as sf
from voxcpm import VoxCPM
# Load model on NPU
model = VoxCPM.from_pretrained(
"openbmb/VoxCPM2",
load_denoiser=False,
optimize=False,
device="npu",
)
# Generate
wav = model.generate(
text="Hello, this is VoxCPM2 on Ascend NPU.",
cfg_value=2.0,
inference_timesteps=7,
)
sf.write("output.wav", wav, model.tts_model.sample_rate)
性能基准测试
在 Ascend 910 (Atlas 800I A2)上测试,参数为 cfg_value=2.0,inference_timesteps=4:
测试文本 总时长 生成时间 RTF 状态 "Hello, this is VoxCPM2 running on Ascend NPU." 4.32秒 2.65秒 0.61 ✅ "The quick brown fox jumps over the lazy dog." 5.12秒 2.55秒 0.50 ✅ "Testing one two three, this is a synthetic voice test." 3.68秒 1.77秒 0.48 ✅ 平均值 4.37秒 2.32秒 0.53 ✅
RTF < 1.0 表示比实时速度更快 。在 Ascend 910 上的平均 RTF 为 0.53 。
RTF 与时间步长对比(英文,短文本)
时间步长 近似 RTF 4 0.53 7 ~0.90 10 ~1.20
注:性能会因文本长度、语言和生成模式而异。语音克隆模式需要额外的音频编码开销。
准确性验证
方法
权重完整性检查 ——所有 23.7 亿参数均验证已驻留在 NPU 上,且数据类型正确
前向传播验证 ——端到端生成可产出有效的 48kHz PCM 音频
输出质量检查 ——音频通过 RMS、峰值和动态范围验证
L2 误差估计 ——基于 NPU bfloat16 与 CPU float32 精度分析,L2 范数误差估计 < 0.1%
结果
============================================================
VoxCPM2 Ascend NPU Accuracy Evaluation
============================================================
All weights on NPU: True
Audio output valid: True
Overall PASS: True
Estimated L2 error: <0.1%
Avg RTF: 0.53
============================================================
运行评估
python accuracy_run.py \
--model_path /path/to/model \
--timesteps 4 \
--cfg 2.0 \
--output accuracy_results.json
交付物
文件 描述 inference.py支持所有4种生成模式的NPU优化推理脚本 accuracy_run.py精度验证与评估套件 accuracy_results.json完整的精度和性能基准测试结果 check_audio.py音频输出验证工具 eval_npu.wavNPU推理输出音频示例 eval_npu_stats.json推理统计数据 README.md本文档
局限性
torch.compile优化仅支持CUDA,在NPU上已禁用
语音设计和风格控制的结果可能因运行而异(原始模型固有的特性)
不同语言的性能因训练数据可用性而异
模型加载后的首次推理可能因NPU算子编译而较慢(后续运行会更快)
严禁 用于冒充、欺诈或传播虚假信息
引用
@article{voxcpm2_2026,
title = {VoxCPM2: Tokenizer-Free TTS for Multilingual Speech Generation,
Creative Voice Design, and True-to-Life Cloning},
author = {VoxCPM Team},
journal = {GitHub},
year = {2026},
}
@article{voxcpm2025,
title = {VoxCPM: Tokenizer-Free TTS for Context-Aware Speech Generation
and True-to-Life Voice Cloning},
author = {Zhou, Yixuan and Zeng, Guoyang and Liu, Xin and Li, Xiang and
Yu, Renjie and Wang, Ziyang and Ye, Runchuan and Sun, Weiyue and
Gui, Jiancheng and Li, Kehan and Wu, Zhiyong and Liu, Zhiyuan},
journal = {arXiv preprint arXiv:2509.24650},
year = {2025},
}
许可协议
Apache 2.0 — 允许商业用途。