g
gcw_coj3XaOd/supertonic
模型介绍文件和版本Pull Requests讨论分析
下载使用量0

Supertonic TTS ONNX 推理

基于 Supertone Supertonic 模型的 ONNX 推理脚本,支持 CPU 推理。

模型信息

属性值
模型类型TTS (Text-to-Speech)
格式ONNX
采样率44100 Hz
潜在维度144 (24 × 6)
推理管线Flow Matching
运行环境CPU (onnxruntime)

安装依赖

pip install onnxruntime numpy soundfile scipy

快速开始

命令行推理

# 基础用法
python inference.py --text "Hello world."

# 指定语音风格 (M1-M5 男性, F1-F5 女性)
python inference.py --text "Hello world." --voice M1
python inference.py --text "Hello world." --voice F3

# 调整语速 (0.5=慢速, 1.0=正常, 2.0=快速)
python inference.py --text "Hello world." --voice M1 --speed 1.5

# 调整 Flow 步数 (更多步数=更好质量)
python inference.py --text "Hello world." --steps 16

# 基准���试模式
python inference.py --text "Benchmark test." --voice M1 --benchmark

# 列出所有语音风格
python inference.py --list-voices

Python API

from inference import SupertonicTTS, save_wav

# 初始化
tts = SupertonicTTS()

# 单条合成
wav, info = tts.synthesize("Hello world.", voice="M1")
save_wav(wav, "output.wav")

# 批量合成
texts = ["Hello.", "World.", "Testing."]
voices = ["M1", "F1", "M2"]
results = tts.synthesize_batch(texts, voices=voices)

# 调整语速
wav, info = tts.synthesize("Hello world.", voice="M1", speed=1.5)

推理管线

文本 → token IDs (unicode_indexer)
       ↓
token IDs → text_emb (text_encoder, 受 style_ttl 控制)
       ↓
token IDs → duration (duration_predictor, 受 style_dp 控制)
       ↓
Flow Matching 去噪 (vector_estimator, 默认 8 步)
       ↓
latent → wav (vocoder)

推理输出证据

==================================================
  推理摘要
==================================================
  文本:       The quick brown fox jumps over the lazy dog.
  语音风格:   M1
  语速:       1.0
  音频时长:   17.14s
  采样率:     44100 Hz
  Flow步数:   8
  总延迟:     2413.1ms
  RTF:        0.141
  输出文件:   demo_M1.wav
==================================================

性能基准

测试场景平均延迟平均 RTF音频时长
短句~1800ms~0.30~5s
中句~2400ms~0.15~17s
长句~3000ms~0.40~8s

RTF (Real-Time Factor): 0.14-0.45 (实时 2-7x 倍速)

评测脚本

# 完整评测 (精度+性能+语音风格)
python evaluate.py --mode full

# 仅精度测试
python evaluate.py --mode accuracy

# 仅性能测试
python evaluate.py --mode performance

# 仅语音风格验证
python evaluate.py --mode voices

文件说明

onnx/
├── inference.py          # 推理脚本 (主交付件)
├── evaluate.py           # 评测脚本
├── README.md             # 本文档
├── evaluation_report.json # 评测报告
├── demo_M1.wav           # 演示音频
├── demo_F3.wav           # 演示音频
├── text_encoder.onnx     # 文本编码器
├── duration_predictor.onnx # 时长预测器
├── vector_estimator.onnx # Flow Matching 去噪器
├── vocoder.onnx          # ���码器
├── tts.json              # 模型配置
└── unicode_indexer.json  # 文本映射表

../voice_styles/
├── M1.json ~ M5.json     # 男性语音风格
└── F1.json ~ F5.json     # 女性语音风格

可用语音风格

类型风格
男性M1, M2, M3, M4, M5
女性F1, F2, F3, F4, F5
随机random
无条件None (零向量)

参数说明

inference.py

参数默认值说明
--text(必填)要合成的英文文本
--outputoutput.wav输出 WAV 文件路径
--voiceNone语音风格
--steps8Flow Matching 去噪步数
--speed1.0语速调整
--seedNone随机种子 (可复现)
--benchmark-运行基准测试
--list-voices-列出所有语音风格

evaluate.py

参数默认值说明
--modefull评测模式 (full/accuracy/performance/voices)
--steps8Flow Matching 步数
--n-runs5性能测试运行次数

注意事项

  1. ONNX Runtime: 需要安装 onnxruntime (CPU 版本即可)
  2. 内���: 推理需要约 2-4GB 内存
  3. CPU: 推荐 4 核以上 CPU 以获得最佳性能
  4. 文本: 当前仅支持英文文本输入