API DocsAI Model APIsAudioBilibili

Reference Audio TTS

Zero-shot WAV synthesis from speaker reference audio, with optional emotion control.

Submit reference audio and text, extract the speaker voice, then synthesize WAV. Optionally control emotion with emotion reference audio, an 8-dimension emotion vector, or emotion text.

The request is multipart/form-data: file fields carry reference audio, and payload is a JSON string. On success the response is binary WAV, not a JSON URL.

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/infer

Create Reference Audio TTS Request

Pass speaker reference audio and synthesis parameters. Returns WAV audio.

Request Body

Content-Type: multipart/form-data

Example:

{
  "model": "IndexTeam/IndexTTS-2",
  "spk_audio_file": "audio/klee.wav",
  "emo_audio_file": "audio/emo_sad.wav",
  "payload": "{\"input\":\"酒楼丧尽天良,开始借机竞拍房间,哎,一群蠢货。\",\"emo_alpha\":0.8,\"emo_control_method\":1}"
}

Properties:

NameTypeRequiredDescription
modelstringYesModel name. Fixed to IndexTeam/IndexTTS-2
spk_audio_filefileYesSpeaker reference audio used to extract the voice. MP3 / WAV, under 20MB
emo_audio_filefileNoEmotion reference audio. MP3 / WAV, under 20MB. Used when emo_control_method=1
payloadstringYesJSON string containing synthesis parameters

payloadstring(Required)

JSON string with Content-Type application/json. Parsed fields are listed below.

inputstring(Required)

Text to synthesize. Maximum 600 characters.

sample_rateinteger(Optional)

Output sample rate (Hz). Common values: 22050 (default), 44100, 48000.

speednumber(Optional)

Speed factor in [0.25, 4]. Default 1.

gainnumber(Optional)

Gain factor. 1 (default) keeps the original volume.

emo_control_methodinteger(Optional)

Emotion control method. Default 0.

  • 0: No emotion reference
  • 1: Use emo_audio_file
  • 2: Use emo_vec
  • 3: Use emo_text
emo_alphanumber(Optional)

Emotion blend weight. Default 1.

emo_vecnumber[](Optional)

8-dimension emotion vector. Used only when emo_control_method=2. The sum of elements must not exceed 1.5. Default all zeros.

emo_textstring(Optional)

Emotion text description. Used only when emo_control_method=3. Example: 今天股票涨停了,好激动.

use_randomboolean(Optional)

Whether to introduce random emotion variation. Default false.

interval_silenceinteger(Optional)

Silence interval between synthesized text chunks, in milliseconds. Default 200.

Responses

200: Synthesis succeeded; WAV audio stream returned

Content-Type: audio/wav

400: Bad request / invalid parameters

Content-Type: application/json

Request Example

curl -X POST "https://api.autorouter.top/v1/audio/infer" \
  -H "Authorization: Bearer sk-xxxxxx" \
  --output speech.wav \
  -F "model=IndexTeam/IndexTTS-2" \
  -F "spk_audio_file=@audio/klee.wav" \
  -F "emo_audio_file=@audio/emo_sad.wav" \
  -F 'payload={"input":"酒楼丧尽天良,开始借机竞拍房间,哎,一群蠢货。","emo_alpha":0.8,"emo_control_method":1}'

Response Example

<binary WAV audio stream>

Response fields:

NameTypeDescription
(body)binaryWAV audio stream on success, Content-Type: audio/wav
error.messagestringError description (on failure)
error.typestringError type
error.codestringMachine-readable error code
error.paramstringRequest ID or the name of the invalid parameter

Error Handling

HTTP 400 Parameter Errors

ScenarioSuggested Action
Missing spk_audio_file or payloadProvide the required fields
payload.input exceeds 600 charactersShorten the text
Sum of emo_vec elements exceeds 1.5Reduce vector dimensions
Reference audio exceeds 20MB or is not MP3/WAVCompress or convert the format

HTTP 401 / 403 Auth Errors

  • 401 Unauthorized: API Key invalid or expired
  • 403 Forbidden: API Key has no access to this model (check token's model allowlist)

HTTP 402 Insufficient Balance

Returns insufficient user quota. Top up at the AutoRouter console.

On this page