Upload Voice
Upload custom voice material and receive a voice ID for later speech synthesis.
Upload custom voice material for later voice TTS. Speaker audio can be provided as a file, Base64, or a public URL.
On success, the response returns a voice ID with the uspeech: prefix. Use it in the voice field of the Voice TTS endpoint.
Base URL
https://api.autorouter.top— Production
Authentication
BearerAuth: http (bearer)
Authenticate using a Bearer Token.
Format: Authorization: Bearer sk-xxxxxx
Endpoints
POST /v1/audio/voice/upload
Upload Custom Voice
The request includes a voice name, model, and speaker audio. The response returns a voice ID. Audio format is WAV / MP3, the file must not exceed 20MB, and duration must not exceed 30 seconds. Speaker audio must be provided as one of speaker_file, speaker_file_base64, or speaker_url.
Request Body
Content-Type: multipart/form-data or application/x-www-form-urlencoded
Example:
{
"name": "温柔女声",
"model": "IndexTeam/IndexTTS-2",
"speaker_url": "https://example.com/audio/speaker.wav",
"emotion_url": "https://example.com/audio/emotion.wav"
}Properties:
| Name | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Custom voice name. Examples: 温柔女声, 客服音色A |
model | string | Yes | Model name. Example: IndexTeam/IndexTTS-2 |
speaker_file | file | Conditional | Speaker audio file (multipart only). WAV / MP3, max 20MB, max 30 seconds |
speaker_file_base64 | string | Conditional | Speaker audio Base64 |
speaker_url | string | Conditional | Public URL of the speaker audio |
emotion_file | file | No | Emotion reference audio file (multipart only). WAV / MP3, max 20MB |
emotion_file_base64 | string | No | Emotion reference audio Base64 |
emotion_url | string | No | Public URL of the emotion reference audio |
application/x-www-form-urlencoded does not support file fields; use speaker_file_base64 or speaker_url.
speaker_filefile(Conditional)
Speaker audio used to extract voice features. Provide exactly one of speaker_file, speaker_file_base64, or speaker_url.
Limits:
- Format: wav, mp3
- File size: Max 20MB
- Duration: Max 30 seconds. Upstream computes duration from the WAV header
datachunk size. A streaming WAV that never rewrites the real length may be rejected as too long.
Responses
200: Upload succeeded
Content-Type: application/json
400: Bad request / audio constraints not met
Content-Type: application/json
401: Bearer Token invalid or missing
Content-Type: application/json
Request Example
curl -X POST "https://api.autorouter.top/v1/audio/voice/upload" \
-H "Authorization: Bearer sk-xxxxxx" \
-F "name=温柔女声" \
-F "model=IndexTeam/IndexTTS-2" \
-F "speaker_file=@/path/to/speaker.wav" \
-F "emotion_file=@/path/to/emotion.wav"Response Example
{
"id": "uspeech:xxxx-xxxx-xxxx-xxxx"
}Response fields:
| Name | Type | Description |
|---|---|---|
id | string | Custom voice ID in the format uspeech:.. Pass it as voice in later synthesis |
Error Handling
HTTP 400 Parameter Errors
| Scenario | error. |
|---|---|
Missing name | missing_name |
| No speaker audio provided | missing_speaker |
| Invalid Base64 | invalid_speaker_base64 |
| Unsupported audio format | unsupported_audio_format |
| File too large | file_too_large |
| Duration longer than 30 seconds | duration_out_of_range |
| Sample rate too low | sample_rate_too_low |
duration_out_of_range is returned by the upstream provider with HTTP 400 and error.type invalid_request_error. The gateway forwards speaker_file as multipart as-is and only checks file size and extension locally; it does not compute audio duration.
Example:
{
"error": {
"message": "Upstream provider error: audio duration must be <= 30 seconds",
"type": "invalid_request_error",
"code": "duration_out_of_range"
}
}Streaming WAV misread as too long: Some recorders and exporters write streaming WAV files: they first set RIFF chunk size and data chunk size to about 0x7FFFFFFF (~2.1 GB) and never rewrite the real lengths. Python wave and many server-side parsers trust the header data size, compute tens of thousands of seconds, and reject the file. macOS afinfo estimates duration from the actual file size, so the same file may still appear to be only a few seconds long.
Fix: re-export as a standard WAV so the writer backfills the real chunk sizes, or upload MP3 instead.
HTTP 401 / 403 Auth Errors
401 Unauthorized: API Key invalid or expired. Example:{"error":{"message":"Validate Certification failed.","type":"invalid_request_error","code":"auth_error","param":null}}403 Forbidden: API Key has no access to this model
HTTP 402 Insufficient Balance
Returns insufficient user quota. Top up at the AutoRouter console.