Multi-Speaker Dialogue Speech Generation
Synthesize multi-character dialogue text into complete dialogue audio, suited to podcasts, role-play, audiobooks, and course dialogues.
Workflow
POST /v1/audio/speech/speakers
Endpoint
moss-ttsd
Model
Create 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.
Example export MOSS_API_KEY="<your-api-key>"Prepare the request input
Use
modelto specify the model, usespeakersto declare each speaker (id+ a createdvoice_id), then usesegmentsto provide the lines split by speaker.speakers: mapping of speaker id to voice_id segments: lines split by speaker delivery_method and response_format: control whether a URL or audio is returned
request.json { "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" }Send the first request
Send a request to
POST /v1/audio/speech/speakers. Whendelivery_method=url, JSON and a result URL are returned synchronously.curl https://api.mosi.cn/v1/audio/speech/speakers \ -H "Authorization: Bearer $MOSS_API_KEY" \ -H "Content-Type: application/json" \ -d @request.jsonRetrieve the result
When
delivery_method=url, read the result URL from the JSON of the synchronous response. For longer tasks, you can passasync=trueandwebhook_urlto create an asynchronous task, then query it with the returnedtask_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.