You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
1.8 KiB
Markdown

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# GPT_SoVITS 服务 README
## 简要说明
克隆音色并提供实时 TTS Web API可动态切换 GPT/Sovits 权重,支持流式输出。
## 启动
```
python api_v2.py -a 0.0.0.0 -p 9880 -c GPT_SoVITS/configs/tts_infer.yaml
````
## 后台运行与日志
```
nohup python api_v2.py -a 0.0.0.0 -p 9880 -c GPT_SoVITS/configs/tts_infer.yaml > log/gptsovits.log 2>&1 &
tail -n 50 -f log/gptsovits.log
```
## 主要接口
### 1. /tts
合成语音GET/POST成功返回 WAV 流,失败返回 JSON 错误。
**必需字段POST 示例):**
```json
{
"text": "要合成的文本",
"text_lang": "zh",
"ref_audio_path": "参考音频.wav",
"prompt_lang": "zh"
}
```
可选字段有 `prompt_text`、`aux_ref_audio_paths`、`streaming_mode`、`speed_factor` 等。
### 2. /control
控制服务。`command` 可为 `restart``exit`
GET 示例:
```
/control?command=restart
```
POST 示例:
```json
{ "command": "restart" }
```
### 3. /set\_gpt\_weights
切换 GPT 模型权重:
```
/set_gpt_weights?weights_path=路径.ckpt
```
返回 `"success"` 或错误 JSON。
### 4. /set\_sovits\_weights
切换 Sovits 模型权重:
```
/set_sovits_weights?weights_path=路径.pth
```
返回 `"success"` 或错误 JSON。
## 示例 curl
```
curl --location --request POST 'http://192.168.10.113:9880/tts' \
--header 'Content-Type: application/json' \
--data-raw '{
"text": "先帝创业未半而中道崩殂。",
"text_lang": "zh",
"ref_audio_path": "input/gentle_girl.wav",
"prompt_lang": "zh",
"prompt_text": "刚进直播间的宝子们,左上角先点个关注,点亮咱们家的粉丝灯牌!我是你们的主播陈婉婉,今天给大家准备了超级重磅的福利",
"media_type": "wav",
"streaming_mode": false
}'
```