Run GPT-SoVITS as API
Have you tried running the the GPT-SoVITS as an API?
# WebAPI Documentation
Run with: `python api_v2.py -a 127.0.0.1 -p 9880 -c GPT_SoVITS/configs/tts_infer.yaml`
## Parameters:
- `-a` - Binding address, default "127.0.0.1"
- `-p` - Binding port, default 9880
- `-c` - TTS config file path, default "GPT_SoVITS/configs/tts_infer.yaml"
## Endpoints:
### Text-to-Speech
**Endpoint**: `/tts`
GET Example:
```
http://127.0.0.1:9880/tts?text=example_text&text_lang=zh&ref_audio_path=archive_jingyuan_1.wav&prompt_lang=zh&prompt_text=example_prompt&text_split_method=cut5&batch_size=1&media_type=wav&streaming_mode=true
```
POST Body:
```json
{
"text": "", // Required: Text to synthesize
"text_lang": "", // Required: Text language
"ref_audio_path": "", // Required: Reference audio path
"aux_ref_audio_paths": [], // Optional: Additional reference audios
"prompt_text": "", // Optional: Prompt text
"prompt_lang": "", // Required: Prompt language
"top_k": 5, // Top k sampling
"top_p": 1, // Top p sampling
"temperature": 1, // Sampling temperature
"text_split_method": "cut0", // Text segmentation method
"batch_size": 1, // Inference batch size
"batch_threshold": 0.75, // Batch splitting threshold
"split_bucket": true, // Enable bucket splitting
"speed_factor": 1.0, // Speech speed control
"streaming_mode": false, // Enable streaming response
"seed": -1, // Random seed
"parallel_infer": true, // Enable parallel inference
"repetition_penalty": 1.35 // T2S repetition penalty
}
```
### Control Commands
**Endpoint**: `/control`
Commands:
- "restart": Restart service
- "exit": Stop service
GET Example:
```
http://127.0.0.1:9880/control?command=restart
```
### Model Management
**Set GPT Model**:
```
http://127.0.0.1:9880/set_gpt_weights?weights_path=GPT_SoVITS/pretrained_models/s1bert25hz-2kh-longer-epoch=68e-step=50232.ckpt
```
**Set SoVITS Model**:
```
http://127.0.0.1:9880/set_sovits_weights?weights_path=GPT_SoVITS/pretrained_models/s2G488k.pth
```
Responses:
- Success: Returns "success" with HTTP 200
- Failure: Returns error message with HTTP 400
I translated that from this API file in the repository https://github.com/RVC-Boss/GPT-SoVITS/blob/main/api_v2.py
Public Last updated: 2025-01-15 08:41:29 PM