原项目 https://modelscope.cn/studios/javahui/index-tts2-test/files
该项目在 index-tts 的基础上使用 vllm 库重新实现了 gpt 模型的推理,加速了 index-tts 的推理过程。
重写了 api_server.py 接口。各种接口作用可以通过/docs查看。
这是作者的效果 推理速度在单卡 RTX 4090 上的提升为:
- 单个请求的 RTF (Real-Time Factor):≈0.3 -> ≈0.1
- 单个请求的 gpt 模型 decode 速度:≈90 token / s -> ≈280 token / s
- 并发量:gpu_memory_utilization设置为0.25(约5GB显存)的情况下,实测 16 左右的> 并发无压力(测速脚本参考
simple_test.py)
我测试的是1.5版本在L40上gpu_memory_utilization设置为0.1,并发量16,80个任务有一个生成失败。想要用至少又9G的空余显存空间
现在只有indextts1.5的模型文件。如果有需求,可以自行下载其他版本的模型文件。
# Index-TTS
modelscope download --model kusuriuri/Index-TTS-vLLM --local_dir ./checkpoints/Index-TTS-vLLM
# IndexTTS-1.5
modelscope download --model kusuriuri/Index-TTS-1.5-vLLM --local_dir ./checkpoints/Index-TTS-1.5-vLLM
# IndexTTS-2
modelscope download --model kusuriuri/IndexTTS-2-vLLM --local_dir ./checkpoints/IndexTTS-2-vLLM
使用 fastapi 封装了 api 接口,启动示例如下,请将 --model_dir 改为你的模型的实际路径:默认使用Index-TTS-v1.5
python api_server.py --model_dir /your/path/to/Index-TTS
--model_dir: 必填,模型权重路径--host: 服务ip地址,默认为 6006--port: 服务端口,默认为 0.0.0.0--gpu_memory_utilization: vllm 显存占用率,默认设置为 0.1参考 api_example.py
Word Error Rate (WER) Results for IndexTTS and Baseline Models on the seed-test
| model | zh | en |
|---|---|---|
| Human | 1.254 | 2.143 |
| index-tts (num_beams=3) | 1.005 | 1.943 |
| index-tts (num_beams=1) | 1.107 | 2.032 |
| index-tts-vllm | 1.12 | 1.987 |
基本保持了原项目的性能
目录在 test 文件下
参考 simple_test.py,需先启动 API 服务
问题描述: 启动 API 服务器时出现以下错误:
omegaconf.errors.ConfigAttributeError: Missing key gpt full_key: gpt object_type=dict
根本原因:
项目中包含 Git LFS(Large File Storage)文件,当克隆仓库时默认只下载 LFS 指针文件而非实际文件内容。配置文件 config.yaml 是 LFS 文件,初始状态下仅包含指针信息:
version https://git-lfs.github.com/spec/v1
oid sha256:864280aeb82a722ce561078c7f7f16a63b0c6cb270e9b9566a8ce5bffef38954
size 2494
由于实际配置内容未加载,OmegaConf.load() 无法读取到 gpt 配置项,导致访问 self.cfg.gpt.stop_mel_token 时抛出异常。
解决方案:
手动拉取 LFS 文件(推荐):
cd /workspace/checkpoints/Index-TTS-1.5-vLLM
git lfs pull
针对特定文件拉取:
git lfs pull --include="config.yaml"
验证配置文件内容: 拉取完成后,配置文件应包含完整的 YAML 配置,例如:
gpt:
model_dim: 1280
max_mel_tokens: 800
max_text_tokens: 600
heads: 20
use_mel_codes_as_input: true
mel_length_compression: 1024
layers: 24
number_text_tokens: 12000
number_mel_codes: 8194
start_mel_token: 8192
stop_mel_token: 8193
# ... 其他配置
预防措施: 为确保部署时自动处理 LFS 文件,可在启动脚本中添加:
# 确保所有 LFS 文件已下载
git lfs pull
# 或仅拉取必要的配置文件
git lfs pull --include="*.yaml"
验证修复: 执行上述操作后,重新启动 API 服务器应能正常运行:
source .venv/bin/activate
python api_server.py --model_dir checkpoints/Index-TTS-1.5-vLLM --gpu_memory_utilization 0.10