本仓库提供 kani-tts-450m-0.1-ft 模型在 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.1-ft --local-dir /path/to/kani-tts-450m-0.1-ftpython inference.py \
--model-path /path/to/kani-tts-450m-0.1-ft \
--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.1-ft")
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... | 7.92s | 50.2s | 6.33 |
NPU 推理精度通过与 CPU(float32 参考)逐 token logits 对比验证,主要指标包括余弦相似度、token 匹配率和加权相对误差。
运行精度测试:
python eval_accuracy.py测试文本覆盖英语对话场景,评测结果:
| 文本 | 余弦相似度 | Token匹配率 | 加权相对误差 | 结果 |
|---|---|---|---|---|
| Hello, this is a test of the text to speech system. | 0.999924 | 100.0% | 0.000% | PASS |
| I do believe Marsellus Wallace, my husband, your boss... | 0.999361 | 100.0% | 0.400% | PASS |
| What do you call a lawyer with an IQ of 60? Your honor. | 0.999576 | 100.0% | 0.000% | PASS |
max_new_tokens 不超过 3000,避免生成长度过长导致质量下降