API Platform

Multi-speaker Speech

Multi-speaker text-to-speech (TTSD). Use the speakers array to declare each speaker (id + voice), then use the segments array to provide the lines split per speaker. The voice is specified with voice_id, with values taken from List Voices.

POST
/v1/audio/speech/speakers

Multi-speaker TTS. The request body is JSON; delivery_method=url returns JSON (containing a result URL), while delivery_method=audio (the default) returns the audio binary.

Authentication

Add Authorization: Bearer <API_KEY> to the request header to authenticate. You can generate a key on the "API Keys" page of the console.

Example
curl https://api.mosi.cn/v1/audio/speech/speakers \
  -H "Authorization: Bearer $MOSS_API_KEY"

Supported models

FieldAllowed values
model

moss-ttsd

Request fields

FieldTypeRequiredDescription
modelstringYes

Model name; the value is moss-ttsd.

versionstringNo

Specify a model version that is live and publicly available, e.g. moss-ttsd-20260320; omit it to use the server's current default.

speakersarrayYes

The speaker configuration array, declaring each speaker and its voice; cannot be empty.

speakers[].idstringYes

The speaker identifier, referenced by segments[].speaker.

speakers[].voice_idstringYes

The speaker's voice ID; obtainable from the List Voices or Create Voice endpoint.

segmentsarrayYes

The segment array, giving the lines per speaker; cannot be empty.

segments[].speakerstringYes

The speaker identifier; must match one of speakers[].id.

segments[].textstringYes

The text of this line.

response_formatstringNo

Audio format for synchronous requests, e.g. mp3 / wav; for asynchronous tasks the actual format is subject to the task query response.

delivery_methodstringNo

audio returns the audio directly; url returns JSON and a result URL.

asyncbooleanNo

When set to true, creates an asynchronous task and immediately returns a task object; the audio result is delivered by URL.

webhook_urlstringNo

The HTTPS URL called back after the asynchronous task completes.

Request example

curl https://api.mosi.cn/v1/audio/speech/speakers \
  -H "Authorization: Bearer $MOSS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "moss-ttsd",
    "speakers": [
      { "id": "A", "voice_id": "<speaker_a_voice_id>" },
      { "id": "B", "voice_id": "<speaker_b_voice_id>" }
    ],
    "segments": [
      { "speaker": "A", "text": "How is the progress today?" },
      { "speaker": "B", "text": "The API integration testing is already complete." }
    ],
    "delivery_method": "url",
    "response_format": "mp3"
  }'

Delivery methods

Request modeResponse
Default or delivery_method=audioReturns the audio binary directly; Content-Type varies with response_format
delivery_method=urlReturns JSON containing the audio result URL
async=trueReturns an asynchronous task object; the task result is queried via GET /v1/audio/tasks/{task_id}

Synchronous URL response fields

When delivery_method=url, JSON (containing a result URL) is returned:

FieldTypeAlways returnedDescription
idstringYes

Task / result ID. Synchronous URL JSON responses uniformly use id.

objectstringYes

Always audio.speech.

statusstringYes

Task status, for example SUCCESS.

urlstringYes

The audio result URL.

response_formatstringYes

The actual output audio format, for example mp3.

content_typestringYes

The audio MIME type, for example audio/mpeg.

created_atintegerYes

Creation time, a Unix timestamp in seconds.

Asynchronous creation response fields

Returned immediately when async=true:

FieldTypeAlways returnedDescription
idstringYes

Task ID.

task_idstringYes

Task query ID, usually the same as id.

objectstringYes

Always audio.speech.

statusstringYes

Initial status, for example PENDING.

retry_afterintegerNo

Suggested polling interval, in seconds.

created_atintegerYes

Creation time, a Unix timestamp in seconds.

updated_atintegerNo

Update time, a Unix timestamp in seconds.

Response example

Response example
{
  "id": "task_abc123",
  "object": "audio.speech",
  "status": "SUCCESS",
  "url": "https://cdn.example.com/out.mp3",
  "response_format": "mp3",
  "content_type": "audio/mpeg",
  "created_at": 1710000000
}

Next steps