Audio modelsAudio guide

Audio guide

Integration steps

  1. Get an API Key. See Authentication for how to send it.
  2. Choose a voice: use a preset voice, or upload your own voice reference by following Uploads.
  3. Submit a job: speech synthesis, audio composition and voice design are asynchronous jobs that return 202 with a job ID. Send a unique Idempotency-Key with every generation request.
  4. Learn when the job ends through Retrieve a job or a webhook, then call Retrieve a job result for the download URL.

For a comparison of the three capabilities' endpoints, inputs and billing, see Audio model overview.

Speech synthesis

Call POST /v1/tts. Select a speech model with model, then specify a voice and optional emotion control.

Choose a model

modelBest forRequired fieldsText limit
indextts-2 (default)Fine emotion control with reference audio or an eight-dimensional vectortext, one voice2048 characters
indextts-2.5Chinese, English or Japanese voice-over, speed control, emotion described in wordstext, language (ZH, EN or JA)2000 characters, including at least one letter or digit

model defaults to indextts-2. language, speed and emo_text can only be used with indextts-2.5; emo_asset_id, emo_ref_key, emo_vector and emo_alpha can only be used with indextts-2. An unsupported model or field combination returns 422.

Choose a voice

The voice fields below are mutually exclusive; use at most one per request. indextts-2 requires a voice. indextts-2.5 uses a default voice when none is given, but we recommend specifying one.

FieldWhere the value comes from
voice_preset_idA voice ID from the preset voice catalog
voice_asset_idA voice asset ID of your account: a voice reference uploaded and confirmed with purpose: "voice_reference", or a saved designed voice
voice_ref_keyA voice reference value. For voice references registered through the upload endpoints, use voice_asset_id

Voice references must be WAV files of up to 20 MiB. When indextts-2.5 uses an uploaded voice reference, the recording must be 0.5–15 seconds long. Only unexpired assets of your own account can be referenced.

Make sure you have the right to use any voice you upload. You can send rights_confirmed: true when uploading to record your confirmation, but this does not replace obtaining permission.

The voice asset endpoints for listing, renaming, deleting and previewing saved voices accept only console login credentials. With an API Key, reference your own voices directly in generation requests through voice_asset_id.

Emotion control

By default the emotion follows the voice itself. To adjust it, use the method for your model below. See the speech synthesis endpoint for field types and value ranges.

indextts-2: use either emotion reference audio or an emotion vector.

MethodFieldDescription
Emotion reference audioemo_asset_id or emo_ref_keyA WAV of up to 20 MiB uploaded and confirmed with purpose: "emotion_reference"; pass its asset_id as emo_asset_id. The two fields are mutually exclusive
Emotion vectoremo_vectorEight weights in a fixed order, each 0–1.4; 0–1 is recommended

emo_alpha sets the overall strength of the emotion vector, from 0 to 1, default 1. indextts-2 does not support emotion descriptions; emo_text returns 422.

The eight vector dimensions are, in order: happy, angry, sad, afraid, disgusted, melancholic, surprised and calm. For example, a calm tone:

{"text":"Hello from Shixu.","voice_preset_id":"vp_000000000000000000000001","emo_vector":[0,0,0,0,0,0,0,1]}

indextts-2.5: describe the emotion in one sentence with emo_text, up to 200 characters, such as "a lowered voice with a hint of a smile". When omitted, the model infers the emotion from the text. Adjust speed with speed, from 0.5 to 2, default 1.

{"model":"indextts-2.5","language":"EN","text":"Hello from Shixu.","speed":1.1,"emo_text":"Warm and relaxed, like chatting with a friend"}

Request examples

With indextts-2:

curl -X POST 'https://shixux.com/api/v1/tts' \
  -H 'X-API-Key: yb_xxx_yyy' \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: speech-001' \
  -d '{"text":"Hello from Shixu.","voice_preset_id":"vp_000000000000000000000001","emo_vector":[0,0,0,0,0,0,0,1]}'

With indextts-2.5:

curl -X POST 'https://shixux.com/api/v1/tts' \
  -H 'X-API-Key: yb_xxx_yyy' \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: speech-002' \
  -d '{"model":"indextts-2.5","language":"EN","text":"Hello from Shixu.","voice_preset_id":"vp_000000000000000000000001","speed":1.1,"emo_text":"Warm and relaxed, like chatting with a friend"}'

To call indextts-2.5 from Python or JavaScript, add the same model, language and optional speed and emo_text to the request body.

Audio composition

Audio composition mixes multiple speech lines, sound effects and music into one WAV file. Speech is generated from the script by the speech model. Sound effects and music use audio assets you upload (purpose: "audio_material"), which are trimmed, looped and mixed along the timeline.

model applies to all speech segments and can be indextts-2 (default) or indextts-2.5. With indextts-2.5, language is required and speed and emo_text are available. The default voice is set with voice_preset_id or voice_asset_id; voice_ref_key, emotion reference audio and emotion vectors are not supported.

Write the timeline

prompt_document is a structured document with version 1, made of text parts and reference parts. text parts carry the script and timeline text, and reference parts refer to a voice or audio asset by reference_id and label. The timeline text uses this format:

[00:00] Alex: Welcome back.
[00:03.250] Sam: Let's start recording.
音效 [00:05–00:08] @Footsteps
配乐 [00:00–00:12] @Background music
  • A speech line starts with its start time; its end is determined by the length of the generated audio.
  • Sound effect and music lines start with 音效 (sound effect) or 配乐 (music), must give a full time range and reference one audio asset after the range.
  • Each line may contain only one start time or one time range.
  • A composition may have up to 64 segments, up to 5000 characters of script in total and a timeline of up to 10 minutes.

When prompt_document is omitted, text is parsed as a simple timeline of speech lines that use the default voice from the request.

Quote and submit

Call Quote an audio composition first. credits in the response is the estimated charge and segments is the number of speech segments; quoting does not create a job. Then submit the same body to Create an audio composition.

curl -X POST 'https://shixux.com/api/v1/audio/compositions/quote' \
  -H 'X-API-Key: yb_xxx_yyy' \
  -H 'Content-Type: application/json' \
  -d '{"text":"[00:00] Welcome back.","prompt_document":{"version":1,"parts":[{"type":"text","text":"[00:00] Welcome back."}]},"voice_preset_id":"vp_000000000000000000000001"}'

Creating an audio composition requires an Idempotency-Key; keep it unchanged when retrying. If a composition fails or is stopped, call Resume an audio composition to continue. Completed speech segments are reused rather than generated again.

Voice design

Voice design generates a new voice from a text description, without uploading recordings.

  1. Call Get voice design configuration to check availability and read the rate per generation and its version billing.version.
  2. Call Design a voice from a description with name (1–80 characters), description (1–500 characters), preview_text (15–200 characters), language and quote_version. The configuration's languages field lists the available languages from zh, en, ja and ko.
  3. When the job succeeds, listen to the result. If you are satisfied, call Save a designed voice to add it to your account's voice library. Saving the same candidate again is not charged again.
  4. After saving, use the returned voice ID as voice_asset_id for speech synthesis.

Jobs, results and errors

Audio job states are queued, processing, succeeded, failed and cancelled. After success, call Retrieve a job result for the download URL, and call it again for a new URL after it expires.

Common submission errors:

  • 422: unsupported model, missing language, or a field the selected model does not support.
  • 402: not enough credits.
  • 409: the idempotency key was already used for a different request.
  • 503: the selected model is temporarily unavailable; retry later with the same idempotency key.

For more rules, see Uploads, Webhooks, Asynchronous jobs and Billing and credits.

On this page