Commit 47249325 authored by yangzhong's avatar yangzhong
Browse files

Update README.md

parent ab9c00af
<a href="README.md">中文</a><a href="README_EN.md">English</a> # IndexTTS-vLLM
<div align="center"> ## 论文
# IndexTTS-vLLM IndexTTS2: A Breakthrough in Emotionally Expressive and Duration-Controlled Auto-Regressive Zero-Shot Text-to-Speech
</div>
https://arxiv.org/abs/2506.21619
## 项目简介
该项目在 [index-tts](https://github.com/index-tts/index-tts) 的基础上使用 vllm 库重新实现了 gpt 模型的推理,加速了 index-tts 的推理过程。 ## 模型结构
推理速度(Index-TTS-v1/v1.5)在单卡 RTX 4090 上的提升为: IndexTTS2 是 B 站提出的零样本可控 TTS 模型,采用 “自回归 + 非自回归” 级联架构,核心由 Text‑to‑Semantic(T2S)、Semantic‑to‑Mel(S2M)、BigVGANv2 声码器 三大模块组成,支持精确时长控制与情感‑音色解耦,适配零样本语音合成与视频配音等场景。
- 单个请求的 RTF (Real-Time Factor):≈0.3 -> ≈0.1 模型采用三阶段流水线,输入文本、音色 / 风格提示、可选时长控制,输出高保真语音,流程如下:
- 单个请求的 gpt 模型 decode 速度:≈90 token / s -> ≈280 token / s 1.文本→语义 Token(T2S):自回归生成带时长 / 情感约束的语义 Token;
- 并发量:gpu_memory_utilization 设置为 0.25(约5GB显存)的情况下,实测 16 左右的并发无压力(测速脚本参考 `simple_test.py` 2.语义 Token→梅尔频谱(S2M):非自回归流匹配生成梅尔谱,融入 GPT 隐表示保障情感清晰度;
3.梅尔频谱→波形(声码器):BigVGANv2 转波形,兼顾音质与推理速度。
## 更新日志
![mammoth_github](https://developer.sourcefind.cn/codes/modelzoo/MAmmoTH/-/raw/master/picture/mammoth_github.png?inline=false)
- **[2025-09-22]** 支持了 vllm v1 版本,IndexTTS2 正在兼容中
## 环境配置
- **[2025-09-28]** 支持了 IndexTTS2 的 webui 推理,并整理了权重文件,现在部署更加方便了! \0.0/ ;但当前版本对于 IndexTTS2 的 gpt 似乎并没有加速效果,待研究
### Docker(方法一)
- **[2025-09-29]** 解决了 IndexTTS2 的 gpt 模型推理加速无效的问题
```
- **[2025-10-09]** 兼容 IndexTTS2 的 api 接口调用,请参考 [API](#api);v1/1.5 的 api 接口以及 openai 兼容的接口可能还有 bug,晚点再修 在光源可拉取docker镜像:
docker pull image.sourcefind.cn:5000/dcu/admin/base/vllm:0.9.2-ubuntu22.04-dtk25.04.1-rc5-rocblas104381-0915-das1.6-py3.10-20250916-rc2-ds3.2
- **[2025-10-19]** 支持 qwen0.6bemo4-merge 的 vllm 推理 创建并启动容器:
docker run -it --network=host --name=dtk25041_torch25 -v /opt/hyhal:/opt/hyhal:ro -v /usr/local/hyhal:/usr/local/hyhal:ro -v /public:/public:ro --privileged --device=/dev/kfd --device=/dev/dri --ipc=host --shm-size=128G --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -u root --ulimit stack=-1:-1 --ulimit memlock=-1:-1 image.sourcefind.cn:5000/dcu/admin/base/vllm:0.9.2-ubuntu22.04-dtk25.04.1-rc5-rocblas104381-0915-das1.6-py3.10-20250916-rc2-ds3.2
## TODO list docker exec -it dtk25041_torch25 /bin/bash
- V2 api 的并发优化:目前只有 gpt2 模型的推理是并行的,其他模块均是串行,而其中 s2mel 的推理开销大(需要 DiT 迭代 25 步),十分影响并发性能 安装依赖包:
cd index-tts-vllm/
- s2mel 的推理加速 pip install http://112.11.119.99:18000/customized/vllm/dtk25.04.1/vllm-0.10.2%2Bdas.opt1.alpha.dfe1a84.dtk25041-cp310-cp310-linux_x86_64.whl # 安装vllm0.10.2
pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
## 使用步骤 pip install http://112.11.119.99:18000/customized/torchaudio/dtk25.04.2/torchaudio251-hip/torchaudio-2.5.1%2Bdas.opt1.dtk25042-cp310-cp310-manylinux_2_28_x86_64.whl --force-reinstall --no-deps # 安装指定版本的torchaudio
# 安装Qt5
### 1. git 本项目 apt update && apt install -y libqt5core5a libgstreamer-plugins-good1.0-0 gstreamer1.0-plugins-base
```bash # vllm必须安装指定的0.10.2版本,torchaudio需要卸载安装指定whl包
git clone https://github.com/Ksuriuri/index-tts-vllm.git ```
cd index-tts-vllm ### Dockerfile(方法二)
```
```
docker build --no-cache -t index-tts-vllm:latest .
### 2. 创建并激活 conda 环境 docker run -dit --network=host --name=index-tts-vllm --privileged --device=/dev/kfd --device=/dev/dri --ipc=host --shm-size=16G --group-add video --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -u root --ulimit stack=-1:-1 --ulimit memlock=-1:-1 -v /opt/hyhal/:/opt/hyhal/:ro -v /usr/local/hyhal:/usr/local/hyhal:ro index-tts-vllm:latest
```bash docker exec -it index-tts-vllm /bin/bash
conda create -n index-tts-vllm python=3.12 安装依赖包:
conda activate index-tts-vllm cd index-tts-vllm/
``` pip install http://112.11.119.99:18000/customized/vllm/dtk25.04.1/vllm-0.10.2%2Bdas.opt1.alpha.dfe1a84.dtk25041-cp310-cp310-linux_x86_64.whl # 安装vllm0.10.2
pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
pip install http://112.11.119.99:18000/customized/torchaudio/dtk25.04.2/torchaudio251-hip/torchaudio-2.5.1%2Bdas.opt1.dtk25042-cp310-cp310-manylinux_2_28_x86_64.whl --force-reinstall --no-deps # 安装指定版本的torchaudio
### 3. 安装 pytorch # 安装Qt5
apt update && apt install -y libqt5core5a libgstreamer-plugins-good1.0-0 gstreamer1.0-plugins-base
需要 pytorch 版本 2.8.0(对应 vllm 0.10.2),具体安装指令请参考:[pytorch 官网](https://pytorch.org/get-started/locally/) # vllm必须安装指定的0.10.2版本,torchaudio需要卸载安装指定whl包
```
### 4. 安装依赖 ### Anaconda(方法三)
```bash
pip install -r requirements.txt ```
``` 1.创建conda虚拟环境:
conda create -n index-tts-vllm python=3.10
2.关于本项目DCU显卡所需的工具包、深度学习库等均可从光合开发者社区下载安装:https://developer.hpccube.com/tool/
### 5. 下载模型权重 DTK驱动:dtk25.04.1
python:python3.10
#### 自动下载(推荐) torch:2.5.1
Tips:以上DTK、python、torch等DCU相关工具包,版本需要严格一一对应
选择对应版本的模型权重下载到 `checkpoints/` 路径下: 3.其它非特殊库参照requirements.txt安装
pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
```bash pip install http://112.11.119.99:18000/customized/vllm/dtk25.04.1/vllm-0.10.2%2Bdas.opt1.alpha.dfe1a84.dtk25041-cp310-cp310-linux_x86_64.whl # 安装vllm0.10.2
# Index-TTS pip install http://112.11.119.99:18000/customized/torchaudio/dtk25.04.2/torchaudio251-hip/torchaudio-2.5.1%2Bdas.opt1.dtk25042-cp310-cp310-manylinux_2_28_x86_64.whl --force-reinstall --no-deps # 安装指定版本的torchaudio
modelscope download --model kusuriuri/Index-TTS-vLLM --local_dir ./checkpoints/Index-TTS-vLLM # 安装Qt5
apt update && apt install -y libqt5core5a libgstreamer-plugins-good1.0-0 gstreamer1.0-plugins-base
# IndexTTS-1.5 # vllm必须安装指定的0.10.2版本,torchaudio需要卸载安装指定whl包
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
```
#### 手动下载 ## 预训练模型
- ModelScope:[Index-TTS](https://www.modelscope.cn/models/kusuriuri/Index-TTS-vLLM) | [IndexTTS-1.5](https://www.modelscope.cn/models/kusuriuri/Index-TTS-1.5-vLLM) | [IndexTTS-2](https://www.modelscope.cn/models/kusuriuri/IndexTTS-2-vLLM) 模型权重下载到 `checkpoints/` 路径下:
#### 自行转换原权重(可选,不推荐) ```
modelscope download --model kusuriuri/IndexTTS-2-vLLM --local_dir ./checkpoints/IndexTTS-2-vLLM
可以使用 `convert_hf_format.sh` 自行转换官方权重文件: ```
```bash ## 推理
bash convert_hf_format.sh /path/to/your/model_dir
``` #### 单机单卡推理
### 6. webui 启动! 使用 fastapi 封装了 api 接口,启动示例如下:
运行对应版本(第一次启动可能会久一些,因为要对 bigvgan 进行 cuda 核编译): ```
python api_server_v2.py
```bash ```
# Index-TTS 1.0
python webui.py #### 启动参数
# IndexTTS-1.5 - `--model_dir`: 必填,模型权重路径
python webui.py --version 1.5 - `--host`: 服务ip地址,默认为 `0.0.0.0`
- `--port`: 服务端口,默认为 `6006`
# IndexTTS-2 - `--gpu_memory_utilization`: vllm 显存占用率,默认设置为 `0.25`
python webui_v2.py
``` #### API 请求示例
```
## API python api_example_v2.py
```
使用 fastapi 封装了 api 接口,启动示例如下:
## result
```bash
# Index-TTS-1.0/1.5
python api_server.py
## 精度
# IndexTTS-2
python api_server_v2.py
```
### 应用场景
### 启动参数
- `--model_dir`: 必填,模型权重路径 ### 算法类别
- `--host`: 服务ip地址,默认为 `0.0.0.0`
- `--port`: 服务端口,默认为 `6006` 文本转语音(TTS)领域
- `--gpu_memory_utilization`: vllm 显存占用率,默认设置为 `0.25`
### 热点应用行业
### API 请求示例
- v1/1.5 请参考 `api_example.py` 医疗,教育,科研,游戏娱乐
- v2 请参考 `api_example_v2.py`
## 源码仓库及问题反馈
### OpenAI API
- 添加 /audio/speech api 路径,兼容 OpenAI 接口 - https://developer.sourcefind.cn/codes/modelzoo/index-tts-vllm
- 添加 /audio/voices api 路径, 获得 voice/character 列表
## 参考资料
详见:[createSpeech](https://platform.openai.com/docs/api-reference/audio/createSpeech) - https://github.com/Ksuriuri/index-tts-vllm
## 新特性
- **v1/v1.5:** 支持多角色音频混合:可以传入多个参考音频,TTS 输出的角色声线为多个参考音频的混合版本(输入多个参考音频会导致输出的角色声线不稳定,可以抽卡抽到满意的声线再作为参考音频)
## 性能
Word Error Rate (WER) Results for IndexTTS and Baseline Models on the [**seed-test**](https://github.com/BytedanceSpeech/seed-tts-eval)
| 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 |
基本保持了原项目的性能
## 并发测试
参考 [`simple_test.py`](simple_test.py),需先启动 API 服务
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment