VoxCPM-0.5B 是基于昇腾 NPU(Ascend 910)适配的端到端语音合成(TTS)模型。该模型在华为昇腾 NPU 上完成推理适配,支持中英文语音合成。
| 组件 | 版本 |
|---|---|
| Python | >= 3.11 |
| PyTorch | 2.9.0 |
| torch_npu | 2.9.0.post1 |
| voxcpm | >= 1.0.3 |
| torchaudio | >= 2.5.0 |
| transformers | >= 4.36.2 |
| soundfile | >= 0.13.0 |
pip install modelscope
python -c "
from modelscope import snapshot_download
model_dir = snapshot_download('xiaowangge/voxcpm-0.5b')
print(f'Model downloaded to: {model_dir}')
"pip install voxcpm torch_npu soundfile# 英文文本合成
python inference.py \
--text "Hello world, this is a test of VoxCPM on Ascend NPU." \
--output output.wav \
--device npu:0 \
--timesteps 4
# 中文文本合成
python inference.py \
--text "你好,这是VoxCPM在华为昇腾NPU上的推理测试。" \
--output output_cn.wav \
--device npu:0 \
--timesteps 4
# 带参考音频的合成
python inference.py \
--text "VoxCPM generates highly realistic speech." \
--prompt-audio example.wav \
--prompt-text "Just by listening a few minutes a day." \
--output output_prompt.wav \
--device npu:0
# 性能基准测试
python inference.py \
--text "Hello world, this is a test." \
--output benchmark.wav \
--device npu:0 \
--benchmark --benchmark-runs 10python evaluate.py --output-dir evaluation_resultsvoxcpm 添加 NPU 设备支持bfloat16 精度,与 CUDA 保持一致torch.compile 优化(CUDA 专用特性)import torch_npu
from voxcpm.model import utils
# 扩展设备分辨率,支持 "npu:0", "npu:1" 等设备标识
utils.resolve_runtime_device = patched_resolve_runtime_device
utils.auto_select_device = patched_auto_select_device测试环境:Ascend 910 NPU, torch_npu 2.9.0
| 测试用例 | 文本 | 推理步数 | 生成时长 | 推理时间 | RTF |
|---|---|---|---|---|---|
| english_short | "Hello world..." (英) | 4 | 3.76s | 2.70s | 0.719 |
| chinese_short | "你好,这是..." (中) | 4 | 4.72s | 2.76s | 0.585 |
| english_long | "VoxCPM is an..." (英) | 10 | 13.52s | 13.39s | 0.990 |
模型加载时间: 12.08s
RTF 说明: RTF(Real-Time Factor)< 1 表示推理速度快于实时播放速度。
| 指标 | 数值 |
|---|---|
| 平均推理时间 | 2.47s |
| 标准差 | 0.18s |
| 最小推理时间 | 2.28s |
| 最大推理时间 | 2.70s |
| 测试用例 | RMS | Peak | Crest Factor | ZCR |
|---|---|---|---|---|
| english_short | 0.068 | 0.729 | 10.67 | 0.196 |
| chinese_short | 0.116 | 0.913 | 7.89 | 0.169 |
| english_long | 0.136 | 0.839 | 6.16 | 0.196 |
所有输出均为有效音频信号,无异常值(NaN/Inf),幅值范围合理。
VoxCPM 是基于扩散模型 (CFM) 的 TTS 模型,每次推理使用随机噪声采样,因此同一输入在不同运行中生成的音频在波形层面存在天然差异。这是扩散模型的正常特性,不影响生成语音的质量和自然度。
| 文件 | 说明 |
|---|---|
inference.py | NPU 推理脚本,支持命令行参数 |
evaluate.py | 精度与性能评测脚本 |
evaluation_results/ | 评测输出目录(音频 + 报告) |
test_npu_output.wav | NPU 推理输出示例 |
README.md | 本部署文档 |
本项目基于 Apache License 2.0 开源。