Update index-stream-integration.md

This commit is contained in:
Alireza Jahanshahlou 2025-10-12 17:33:37 +03:30 committed by GitHub
parent 21429705a2
commit 34bfc6ee6f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,80 +1,80 @@
# IndexStreamTTS 使用指南 # IndexStreamTTS Usage Guide
## 环境准备 ## Environment Preparation
### 1. 克隆项目 (注意这里使用的为VLLM1.0的Releases版本) ### 1. Clone the project (note that the release version of VLLM1.0 is used here)
```bash ```bash
https://github.com/Ksuriuri/index-tts-vllm/releases/tag/IndexTTS-vLLM-1.0 https://github.com/Ksuriuri/index-tts-vllm/releases/tag/IndexTTS-vLLM-1.0
``` ```
进入解压后的目录 Enter the unzipped directory
```bash ```bash
cd index-tts-vllm cd index-tts-vllm
``` ```
### 2. 创建并激活 conda 环境 ### 2. Create and activate a conda environment
```bash ```bash
conda create -n index-tts-vllm python=3.12 conda create -n index-tts-vllm python=3.12
conda activate index-tts-vllm conda activate index-tts-vllm
``` ```
### 3. 安装PyTorch 需要版本为2.8.0(最新版) ### 3. Install PyTorch. Version 2.8.0 (latest version) is required.
#### 查看显卡最高支持的版本和实际安装的版本 #### Check the highest supported version of the graphics card and the actual installed version
```bash ```bash
nvidia-smi nvidia-smi
nvcc --version nvcc --version
``` ```
#### 驱动支持的最高 CUDA 版本 #### Highest CUDA version supported by the driver
```bash ```bash
CUDA Version: 12.8 CUDA Version: 12.8
``` ```
#### 实际安装的 CUDA 编译器版本 #### Actual installed CUDA compiler version
```bash ```bash
Cuda compilation tools, release 12.8, V12.8.89 Cuda compilation tools, release 12.8, V12.8.89
``` ```
#### 那么对应的安装命令(pytorch默认给的是12.8的驱动版本) #### Then the corresponding installation command (pytorch defaults to the 12.8 driver version)
```bash ```bash
pip install torch torchvision pip install torch torchvision
``` ```
需要 pytorch 版本 2.8.0(对应 vllm 0.10.2),具体安装指令请参考:[pytorch 官网](https://pytorch.org/get-started/locally/) You need PyTorch version 2.8.0 (corresponding to VLLM 0.10.2). For specific installation instructions, please refer to the [PyTorch official website](https://pytorch.org/get-started/locally/)
### 4. 安装依赖 ### 4. Install dependencies
```bash ```bash
pip install -r requirements.txt pip install -r requirements.txt
``` ```
### 5. 下载模型权重 ### 5. Download model weights
此为官方权重文件,下载到本地任意路径即可,支持 IndexTTS-1.5 的权重 This is the official weight file, which can be downloaded to any local path. It supports the weight of IndexTTS-1.5.
| HuggingFace | ModelScope | | HuggingFace | ModelScope |
|---------------------------------------------------------------|---------------------------------------------------------------------| |---------------------------------------------------------------|---------------------------------------------------------------------|
| [IndexTTS](https://huggingface.co/IndexTeam/Index-TTS) | [IndexTTS](https://modelscope.cn/models/IndexTeam/Index-TTS) | | [IndexTTS](https://huggingface.co/IndexTeam/Index-TTS) | [IndexTTS](https://modelscope.cn/models/IndexTeam/Index-TTS) |
| [IndexTTS-1.5](https://huggingface.co/IndexTeam/IndexTTS-1.5) | [IndexTTS-1.5](https://modelscope.cn/models/IndexTeam/IndexTTS-1.5) | | [IndexTTS-1.5](https://huggingface.co/IndexTeam/IndexTTS-1.5) | [IndexTTS-1.5](https://modelscope.cn/models/IndexTeam/IndexTTS-1.5) |
下面以ModelScope的安装方法为例 The following is an example of how to install ModelScope
### 请注意:git需要安装并初始化启用lfs(如已安装可以跳过) ### Please note: Git needs to be installed and initialized to enable LFS (if already installed, you can skip this step)
```bash ```bash
sudo apt-get install git-lfs sudo apt-get install git-lfs
git lfs install git lfs install
``` ```
创建模型目录,并拉取模型 Create a model directory and pull the model
```bash ```bash
mkdir model_dir mkdir model_dir
cd model_dir cd model_dir
git clone https://www.modelscope.cn/IndexTeam/IndexTTS-1.5.git git clone https://www.modelscope.cn/IndexTeam/IndexTTS-1.5.git
``` ```
### 5. 模型权重转换 ### 5. Model weight conversion
```bash ```bash
bash convert_hf_format.sh /path/to/your/model_dir bash convert_hf_format.sh /path/to/your/model_dir
``` ```
例如:你下载的IndexTTS-1.5模型存放在model_dir目录下,则执行以下命令 For example, if the IndexTTS-1.5 model you downloaded is stored in the model_dir directory, execute the following command:
```bash ```bash
bash convert_hf_format.sh model_dir/IndexTTS-1.5 bash convert_hf_format.sh model_dir/IndexTTS-1.5
``` ```
此操作会将官方的模型权重转换为 transformers 库兼容的版本,保存在模型权重路径下的 vllm 文件夹中,方便后续 vllm 库加载模型权重 This operation will convert the official model weights into a version compatible with the transformers library and save it in the vllm folder under the model weight path, making it easier to load the model weights in the vllm library later.
### 6. 更改接口适配一下项目 ### 6. Change the interface to adapt to the project
接口返回数据与项目不适配需要调整一下,使其直接返回音频数据 The data returned by the interface is not compatible with the project and needs to be adjusted to return the audio data directly.
```bash ```bash
vi api_server.py we api_server.py
``` ```
```bash ```bash
@app.post("/tts", responses={ @app.post("/tts", responses={
@ -104,85 +104,85 @@ async def tts_api(request: Request):
) )
``` ```
### 7.编写sh启动脚本(请注意要在相应的conda环境下运行) ### 7. Write the sh startup script (please note that it must be run in the corresponding conda environment)
```bash ```bash
vi start_api.sh we start_api.sh
``` ```
### 将下面内容粘贴进去并按:输入wq保存 ### Paste the following content and press: Enter wq to save
#### 脚本中的/home/system/index-tts-vllm/model_dir/IndexTTS-1.5 请自行修改为实际路径 #### Please modify the /home/system/index-tts-vllm/model_dir/IndexTTS-1.5 in the script to the actual path
```bash ```bash
# 激活conda环境 # Activate the conda environment
conda activate index-tts-vllm conda activate index-tts-vllm
echo "激活项目conda环境" echo "Activate project conda environment"
sleep 2 sleep 2
# 查找占用11996端口的进程号 # Find the process number occupying port 11996
PID_VLLM=$(sudo netstat -tulnp | grep 11996 | awk '{print $7}' | cut -d'/' -f1) PID_VLLM=$(sudo netstat -tulnp | grep 11996 | awk '{print $7}' | cut -d'/' -f1)
# 检查是否找到进程号 # Check if the process ID is found
if [ -z "$PID_VLLM" ]; then if [ -z "$PID_VLLM" ]; then
echo "没有找到占用11996端口的进程" echo "No process occupying port 11996 was found"
else else
echo "找到占用11996端口的进程,进程号为: $PID_VLLM" echo "Found the process occupying port 11996, process ID: $PID_VLLM"
# 先尝试普通kill,等待2秒 # Try a normal kill first, wait 2 seconds
kill $PID_VLLM kill $PID_VLLM
sleep 2 sleep 2
# 检查进程是否还在 # Check if the process is still alive
if ps -p $PID_VLLM > /dev/null; then if ps -p $PID_VLLM > /dev/null; then
echo "进程仍在运行,强制终止..." echo "The process is still running, force terminate..."
kill -9 $PID_VLLM kill -9 $PID_VLLM
fi be
echo "已终止进程 $PID_VLLM" echo "Process $PID_VLLM has been terminated"
fi be
# 查找占用VLLM::EngineCore进程 # Find the process occupying VLLM::EngineCore
GPU_PIDS=$(ps aux | grep -E "VLLM|EngineCore" | grep -v grep | awk '{print $2}') GPU_PIDS=$(ps aux | grep -E "VLLM|EngineCore" | grep -v grep | awk '{print $2}')
# 检查是否找到进程号 # Check if the process ID is found
if [ -z "$GPU_PIDS" ]; then if [ -z "$GPU_PIDS" ]; then
echo "没有找到VLLM相关进程" echo "No VLLM related process found"
else else
echo "找到VLLM相关进程,进程号为: $GPU_PIDS" echo "Found VLLM related process, process ID: $GPU_PIDS"
# 先尝试普通kill,等待2秒 # Try a normal kill first, wait 2 seconds
kill $GPU_PIDS kill $GPU_PIDS
sleep 2 sleep 2
# 检查进程是否还在 # Check if the process is still alive
if ps -p $GPU_PIDS > /dev/null; then if ps -p $GPU_PIDS > /dev/null; then
echo "进程仍在运行,强制终止..." echo "The process is still running, force terminate..."
kill -9 $GPU_PIDS kill -9 $GPU_PIDS
fi be
echo "已终止进程 $GPU_PIDS" echo "Process $GPU_PIDS has been terminated"
fi be
# 创建tmp目录(如果不存在) # Create the tmp directory (if it does not exist)
mkdir -p tmp mkdir -p tmp
# 后台运行api_server.py,日志重定向到tmp/server.log # Run api_server.py in the background and redirect the log to tmp/server.log
nohup python api_server.py --model_dir /home/system/index-tts-vllm/model_dir/IndexTTS-1.5 --port 11996 > tmp/server.log 2>&1 & nohup python api_server.py --model_dir /home/system/index-tts-vllm/model_dir/IndexTTS-1.5 --port 11996 > tmp/server.log 2>&1 &
echo "api_server.py 已在后台运行,日志请查看 tmp/server.log" echo "api_server.py is running in the background. Please check tmp/server.log for the logs."
``` ```
给脚本执行权限并运行脚本 Give the script execute permission and run the script
```bash ```bash
chmod +x start_api.sh chmod +x start_api.sh
./start_api.sh ./start_api.sh
``` ```
日志会在tmp/server.log中输出,可以通过以下命令查看日志情况 The log will be output in tmp/server.log. You can view the log status by the following command
```bash ```bash
tail -f tmp/server.log tail -f tmp/server.log
``` ```
## 音色配置 ## Tone Configuration
index-tts-vllm支持通过配置文件注册自定义音色,支持单音色和混合音色配置。 index-tts-vllm supports registering custom timbres through configuration files, and supports single-timbre and mixed-timbre configurations.
在项目根目录下的assets/speaker.json文件中配置自定义音色 Configure custom timbre in the assets/speaker.json file in the project root directory
### 配置格式说明 ### Configuration format description
```bash ```bash
{ {
"说话人名称1": [ "Speaker Name 1": [
"音频文件路径1.wav", "Audio file path 1.wav",
"音频文件路径2.wav" "Audio file path 2.wav"
], ],
"说话人名称2": [ "Speaker Name 2": [
"音频文件路径3.wav" "Audio file path 3.wav"
] ]
} }
``` ```
### 注意 (需重启服务进行注册) ### Note (need to restart the service to register)
添加后需在智控台中添加相应的说话人(单模块则更换相应的voice) After adding, you need to add the corresponding speaker in the smart console (for single module, change the corresponding voice)