本文档记录 mms-tts-uig-script_arabic-UQSpeech 在华为昇腾 Ascend 910B NPU 上的适配、部署与验证结果。
该模型是基于 Facebook MMS (Massively Multilingual Speech) VITS 架构微调得到的维吾尔语(阿拉伯文脚本)文本转语音(TTS)模型,由 UQSpeech 项目发布。模型参数量约 36M,适用于维吾尔语语音合成场景。
适配要点:
torch_npu 将 PyTorch 模型迁移至 Ascend NPUtransfer_to_npu 自动完成 CUDA 到 NPU 的 API 映射相关获取地址:
| 组件 | 版本 |
|---|---|
CANN | 8.5.1 |
torch | 2.5.1 |
torch-npu | 2.5.1.dev20260320 |
transformers | 4.47.1 |
scipy | 1.17.1 |
Ascend 910B4(1 卡,32GB HBM)Linux 5.10.0 aarch64# 安装依赖
pip install torch transformers scipy
# 确保 CANN 和 torch_npu 已正确安装
# 参考: https://www.hiascend.com/document/# 方式一:从 HuggingFace 镜像下载
export HF_ENDPOINT=https://hf-mirror.com
huggingface-cli download ixxan/mms-tts-uig-script_arabic-UQSpeech \
--local-dir ./model --local-dir-use-symlinks False
# 方式二:从 ModelScope 下载
modelscope download --model ixxan/mms-tts-uig-script_arabic-UQSpeech --local_dir ./modelpython inference.py \
--model_path ./model \
--text "مەن بىر ئادەممەن." \
--output output.wav参数说明:
| 参数 | 说明 | 默认值 |
|---|---|---|
--model_path | 模型权重路径 | ./model |
--text | 输入维吾尔语文本 | مەن بىر ئادەممەن. |
--output | 输出音频路径 | output.wav |
--speaking_rate | 语速倍率 | 1.0 |
--benchmark | 启用性能测试模式 | False |
由于 VITS 模型采用随机时长预测(use_stochastic_duration_prediction=true)和噪声注入(noise_scale=0.667),每次推理的波形和长度存在随机差异,属于生成式 TTS 的固有特性。因此精度验证聚焦于结构一致性而非逐点波形匹配。
验证维度:
运行命令:
python accuracy_run.py ./model accuracy_report.json验证结果:
| 验证项 | 状态 | 说明 |
|---|---|---|
| NPU 自一致性 | PASS | 梅尔频谱统计量方差 < 1.0 |
| CPU-NPU 结构一致性 | PASS | 梅尔均值差 < 1.0,标准差差 < 1.0 |
| 总体 | PASS | 适配精度符合预期 |
运行命令:
python accuracy_run_perf.py ./model 10 perf_report.jsonNPU 性能结果(10 次迭代,warmup 3 次):
| 指标 | 数值 |
|---|---|
| 平均延迟 | 88.6 ms |
| P50 延迟 | 89.6 ms |
| P90 延迟 | 97.9 ms |
| 最小延迟 | 73.7 ms |
| 最大延迟 | 97.9 ms |
| RTF | 0.041 |
| 字符吞吐 | 199.74 chars/s |
RTF (Real-Time Factor) = 0.041 表示合成速度约为实时播放的 24.4 倍,满足实时推理需求。
.
├── model/ # 模型权重
│ ├── config.json
│ ├── model.safetensors
│ ├── vocab.json
│ └── ...
├── inference.py # NPU 推理脚本
├── accuracy_run.py # 精度验证脚本
├── accuracy_run_perf.py # 性能基准测试脚本
├── accuracy_report.json # 精度验证报告
├── perf_report.json # 性能测试报告
└── readme.md # 本文档transfer_to_npu 会自动替换 torch.cuda.* 为 torch.npu.*,首次 import 会有警告,属正常现象。scipy.io.wavfile 保存 16-bit PCM WAV 文件,无需额外安装 torchcodec。مەن بىر ئادەممەن.)。@article{babu2023xlsr,
title={XLS-R: Self-supervised Cross-lingual Speech Representation Learning at Scale},
author={Babu, Arun and Wang, Changhan and Tjandra, Andros and Lakhotia, Kushal and Xu, Qiantong and Goyal, Naman and Singh, Kritika and von Platen, Patrick and Saraf, Yatharth and Williams, Michael and others},
journal={arXiv preprint arXiv:2111.09296},
year={2021}
}适配方:Ascend-SACT
标签:#NPU #Ascend #TTS #Uyghur
NPU vs CPU 精度对比(CPU 为基线,NPU 为验证目标):
| 指标 | 数值 |
|---|---|
| 测试用例数 | 5(TTS 结构一致性验证) |
| 最大 logits 差异 | N/A(TTS 随机生成模型,详见上文分析) |
| 预测一致性 | 梅尔频谱结构对比:mel_mean_diff < 0.7,mel_std_diff < 0.22 |
| 精度要求 | NPU vs CPU 结构一致性(mel 频谱统计量相近) |
| 精度结论 | ✅ 通过(5/5 测试用例 PASS,NPU 自一致性 + CPU-NPU 结构一致性均通过) |
精度评测源代码和日志详见 eval/ 目录。