本仓库提供 kani-tts-400m-0.3-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-400m-0.3-pt --local-dir /path/to/kani-tts-400m-0.3-ptpython inference.py \
--model-path /path/to/kani-tts-400m-0.3-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-400m-0.3-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... | 6.64s | 65.3s | 9.83 |
NPU 推理精度通过与 CPU(float32 参考)逐 token logits 对比验证,主要指标包括余弦相似度、token 匹配率和加权相对误差。
运行精度测试:
python eval_accuracy.py测试文本覆盖 8 种语言,评测结果:
| 文本 | 余弦相似度 | Token匹配率 | 加权相对误差 | 结果 |
|---|---|---|---|---|
| Hello, this is a test of the text to speech system. | 0.999912 | 100.0% | 0.000% | PASS |
| 今天天气真好。 | 0.999904 | 100.0% | 0.476% | PASS |
| Hola, esto es una prueba. | 0.999700 | 100.0% | 2.817% | PASS |
max_new_tokens 不超过 3000,避免生成长度过长导致质量下降