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.
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.
curl https://api.mosi.cn/v1/audio/speech/speakers \
-H "Authorization: Bearer $MOSS_API_KEY"
Supported models
| Field | Allowed values |
|---|---|
| model |
|
Request fields
| Field | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Model name; the value is |
| version | string | No | Specify a model version that is live and publicly available, e.g. |
| speakers | array | Yes | The speaker configuration array, declaring each speaker and its voice; cannot be empty. |
| speakers[].id | string | Yes | The speaker identifier, referenced by |
| speakers[].voice_id | string | Yes | The speaker's voice ID; obtainable from the List Voices or Create Voice endpoint. |
| segments | array | Yes | The segment array, giving the lines per speaker; cannot be empty. |
| segments[].speaker | string | Yes | The speaker identifier; must match one of |
| segments[].text | string | Yes | The text of this line. |
| response_format | string | No | Audio format for synchronous requests, e.g. |
| delivery_method | string | No |
|
| async | boolean | No | When set to |
| webhook_url | string | No | 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 mode | Response |
|---|---|
Default or delivery_method=audio | Returns the audio binary directly; Content-Type varies with response_format |
delivery_method=url | Returns JSON containing the audio result URL |
async=true | Returns 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:
| Field | Type | Always returned | Description |
|---|---|---|---|
| id | string | Yes | Task / result ID. Synchronous URL JSON responses uniformly use |
| object | string | Yes | Always |
| status | string | Yes | Task status, for example |
| url | string | Yes | The audio result URL. |
| response_format | string | Yes | The actual output audio format, for example |
| content_type | string | Yes | The audio MIME type, for example |
| created_at | integer | Yes | Creation time, a Unix timestamp in seconds. |
Asynchronous creation response fields
Returned immediately when async=true:
| Field | Type | Always returned | Description |
|---|---|---|---|
| id | string | Yes | Task ID. |
| task_id | string | Yes | Task query ID, usually the same as |
| object | string | Yes | Always |
| status | string | Yes | Initial status, for example |
| retry_after | integer | No | Suggested polling interval, in seconds. |
| created_at | integer | Yes | Creation time, a Unix timestamp in seconds. |
| updated_at | integer | No | Update time, a Unix timestamp in seconds. |
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
}