Date: May 26, 2025
This document provides a comprehensive explanation of the API request methods supported by the TTS (Text-to-Speech) server.
📥 Clone Sound
Endpoint: POST /upload_clone
Body Type: form-data
Example
curl --location 'http://127.0.0.1:8000/upload_clone' \
--form 'voice_id="xiage"' \
--form 'ref_text="贝加尔湖是世界上最古老、最深的淡水湖泊,位于俄罗斯西伯利亚地区,湖水极其清澈透明,是世界上最纯净的湖泊之一。"' \
--form 'ref_audio=@"c:\\Users\\Joe\\Documents\\work\\AI_Avatar\\天印大道804号.m4a"'
Response
{
"status": "success",
"message": "Voice 'xiage' cloned successfully",
"ref_text": "贝加尔湖是世界上最古老、最深的淡水湖泊,位于俄罗斯西伯利亚地区,湖水极其清澈透明,是世界上最纯净的湖泊之一。"
}
Note:
ref_text
must match the content of the audio inref_audio
.
📃 Query Voice List
Endpoint: POST /voices
Example
curl --location --request POST 'http://127.0.0.1:8000/voices'
Response
{
"voices": [
"xiaozhu",
"xiage"
]
}
❌ Delete Voice
Endpoint: DELETE /voices/{voice_id}
Example
curl --location --request DELETE 'http://127.0.0.1:8000/voices/xiage'
Response
{
"status": "success",
"message": "Voice 'xiage' deleted successfully"
}
🗣️ Speech Synthesis
Endpoint: POST /tts
Body Type: application/json
Example
curl --location 'http://127.0.0.1:8000/tts' \
--header 'Content-Type: application/json' \
--data '{
"text": "这是一条测试消息",
"voice_id": "xiaozhu",
"output_dir": "../outputs",
"speed": 0.9,
"nfe_step": 16,
"cross_fade_duration": 0.15,
"split_sentences": true,
"remove_silence": true,
"audio_format": "wav",
"type": 1
}'
Response
{
"job_id": "ec3e746b-3645-4c32-95df-225721d67d17",
"status": "pending",
"message": "TTS batch generation (from single tts with split_sentences) queued"
}
Notes:
output_dir
: Custom output directory.
type
: Indicates message type (e.g., chat, live comment). Default is none.
🛑 Cancel All TTS Tasks
Endpoint: POST /cancel_all_tts
Example
curl --location --request POST 'http://127.0.0.1:8000/cancel_all_tts'
Response
{
"status": "success",
"message": "Requested cancellation for 0 jobs",
"cancelled_count": 0
}
Note: Used to clean up all running TTS tasks.
🔍 Query Job Status
Endpoint: GET /job_status/{job_id}
Example
curl --location --globoff 'http://127.0.0.1:8000/job_status/{job_id}'
Response
{
"status": "completed",
"submit_time": 1748272358.188642,
"start_time": 1748272358.1892061,
"end_time": 1748272368.3770256,
"result": {
"output_files": [
"../outputs/priority_xiaozhu_20250526_151238_f6319314_part001.wav"
],
"total_duration": 10.187206029891968,
"voice_id": "xiaozhu",
"sample_rate": 16000,
"segments": 1,
"type": 1,
"job_id": "ec3e746b-3645-4c32-95df-225721d67d17"
},
"processing_duration": 10.187819480895996,
"total_system_duration": 10.18838357925415
}
Note: Track progress and results using the
job_id
.
🚀 Start Smart Copy
Endpoint: POST /start_smartcopy
Body Type: application/json
Example
curl --location 'http://127.0.0.1:8000/start_smartcopy' \
--header 'Content-Type: application/json' \
--data '{
"source_dir": "../outputs",
"target_dir": "../stage"
}'
Response
{
"status": "success",
"message": "SmartCopy process started",
"config": {
"source_dir": "../outputs",
"target_dir": "../stage"
}
}
Note: Copies audio files from source to target using defined logic.
🛑 Stop Smart Copy
Endpoint: POST /stop_smartcopy
Example
curl --location --request POST 'http://127.0.0.1:8000/stop_smartcopy'
Response
{
"status": "success",
"message": "SmartCopy process stopped",
"details": {
"stdout": null,
"stderr": null,
"exit_code": -15
}
}
🧹 Clear Directory
Endpoint: POST /clear_directory
Body Type: application/json
Example
curl --location 'http://127.0.0.1:8000/clear_directory' \
--header 'Content-Type: application/json' \
--data '{
"directory": "../outputs"
}'
Response
{
"status": "success",
"message": "Cleared 60 files from '../outputs'",
"files_cleared": 60,
"errors": 0
}
Note: Deletes all files in the specified directory.
评论