Multi-speaker Speech
Synthesize multi-character dialogue text into complete dialogue audio, suited to podcasts, role-play, audiobooks, and course dialogues.
/v1/audio/speech/speakersmoss-ttsd-1.0Create an API Key
Open the API Key management platform, create an API Key, and save it as an environment variable. Do not write the API Key into client-side code or commit it to a repository.
Environment variable MOSS_API_KEY=<your_api_key_here>Prepare the request input
Use
speakersto declare each speaker andvoice_id, and usesegmentsto assign lines to speakers. Synchronous calls return audio bytes or a result URL according todelivery_method; for long-running work, passasync=trueand query the returnedtask_id.FieldTypeRequirementDescriptionmoss-ttsd-1.0
Mapping between speaker IDs and voice_id values
Ordered text segments associated with speakers.id through speaker
Controls whether a synchronous request returns a URL or audio directly; response_format only controls synchronous output format
Preview a voice and copy its Voice ID into your request.
Browse more voices in the Mossland voice library.
Request body { "model": "moss-ttsd-1.0", "speakers": [ { "id": "speaker_a", "voice_id": "7e5020e3-b88e-4271-a996-2908a182dd32" }, { "id": "speaker_b", "voice_id": "2925f9ce-75af-4354-8757-b52c3e541e8c" } ], "segments": [ { "speaker": "speaker_a", "text": "诶,我最近看了一篇讲人工智能的文章,还挺有意思的,想跟你聊聊。" }, { "speaker": "speaker_b", "text": "哦?是吗,关于啥的啊?又是哪个公司发了什么逆天的新模型吗?" } ], "response_format": "wav", "delivery_method": "audio" }Send the first request
Send a request to the scenario endpoint. A synchronous request returns audio bytes or JSON containing a result URL according to
delivery_method; withasync=true, it immediately returns a task object.Request example curl --fail-with-body -sS -X POST "https://api.mosi.cn/v1/audio/speech/speakers" \ -H "Authorization: Bearer $MOSS_API_KEY" \ -H "Platform: moss-platform" \ -H "Content-Type: application/json" \ -d '{ "model": "moss-ttsd-1.0", "speakers": [ { "id": "speaker_a", "voice_id": "7e5020e3-b88e-4271-a996-2908a182dd32" }, { "id": "speaker_b", "voice_id": "2925f9ce-75af-4354-8757-b52c3e541e8c" } ], "segments": [ { "speaker": "speaker_a", "text": "诶,我最近看了一篇讲人工智能的文章,还挺有意思的,想跟你聊聊。" }, { "speaker": "speaker_b", "text": "哦?是吗,关于啥的啊?又是哪个公司发了什么逆天的新模型吗?" } ], "response_format": "wav", "delivery_method": "audio" }'Retrieve the task result
For synchronous calls with
delivery_method=url, read the result URL from the response JSON. Passingasync=truereturns atask_id; query the task result viaGET /v1/audio/tasks/{task_id}.Query the task curl https://api.mosi.cn/v1/audio/tasks/$TASK_ID \ -H "Authorization: Bearer $MOSS_API_KEY"Verify success
Success indicator: you obtain the complete dialogue audio (
delivery_method=audio) or a result URL (delivery_method=url), and can download or play it.
Next steps
View endpoint: POST /v1/audio/speech/speakers
Multi-speaker dialogue speech generation endpoint. Use speakers to define speakers and voices, and segments to specify text segments. Each speaker uses voice_id to select a voice.
View the model overview
View model IDs, capabilities, and supported scenarios.