本仓库提供 kani-tts-450m-0.2-pt 模型在 Ascend NPU 上的推理适配。
模型说明:
适配方式:
| 组件 | 版本 |
|---|---|
| Python | 3.11 |
| torch | 2.4.0 |
| torch-npu | 2.4.0 |
| transformers | >= 4.57.0 |
| soundfile | >= 0.12.0 |
NPU 环境要求 Ascend 910B4 及以上,驱动版本 24.1.rc1+。
pip install huggingface-hub
export HF_ENDPOINT=https://hf-mirror.com
huggingface-cli download nineninesix/kani-tts-450m-0.2-pt --local-dir /path/to/kani-tts-450m-0.2-ptpython inference.py \
--model-path /path/to/kani-tts-450m-0.2-pt \
--text "Hello, this is a test of the text to speech system." \
--output output.wavimport sys, os
sys.path.insert(0, "/opt/atomgit/output")
from kani_npu import KaniTTSNPU
engine = KaniTTSNPU("/path/to/kani-tts-450m-0.2-pt")
audio = engine("Hello, this is a test of the text to speech system.")
import soundfile as sf
sf.write("output.wav", audio, 22050)| 文本 | 音频时长 | 生成耗时 | 实时率 (RTF) |
|---|---|---|---|
| Hello, this is a test of the text to speech system... | 9.04s | 58.9s | 6.52 |
NPU 推理精度通过与 CPU(float32 参考)逐 token logits 对比验证,主要指标包括余弦相似度、token 匹配率和加权相对误差。
运行精度测试:
python eval_accuracy.py测试文本覆盖 7 种语言,评测结果:
| 文本 | 余弦相似度 | Token匹配率 | 加权相对误差 | 结果 |
|---|---|---|---|---|
| Hello, this is a test of the text to speech system. | 0.999899 | 100.0% | 1.657% | PASS |
| Guten Tag, wie geht es Ihnen? | 0.999855 | 100.0% | 0.000% | PASS |
| Bonjour, comment allez-vous? | 0.999731 | 100.0% | 1.299% | PASS |
max_new_tokens 不超过 3000,避免生成长度过长导致质量下降