Console

Multi-speaker Speech

Synthesize multi-character dialogue text into complete dialogue audio, suited to podcasts, role-play, audiobooks, and course dialogues.

Endpoint
POST/v1/audio/speech/speakers
Model name
moss-ttsd-1.0
  1. 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.

    Environment variable
    MOSS_API_KEY=<your_api_key_here>
  2. Prepare the request input

    Use speakers to declare each speaker and voice_id, and use segments to assign lines to speakers. Synchronous calls return audio bytes or a result URL according to delivery_method; for long-running work, pass async=true and query the returned task_id.

    FieldTypeRequirementDescription
    model: stringRequired

    moss-ttsd-1.0

    speakers: arrayRequired

    Mapping between speaker IDs and voice_id values

    segments: arrayRequired

    Ordered text segments associated with speakers.id through speaker

    delivery_method: stringOptional

    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"
    }
  3. 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; with async=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"
    }'
  4. Retrieve the task result

    For synchronous calls with delivery_method=url, read the result URL from the response JSON. Passing async=true returns a task_id; query the task result via GET /v1/audio/tasks/{task_id}.

    Query the task
    curl https://api.mosi.cn/v1/audio/tasks/$TASK_ID \
      -H "Authorization: Bearer $MOSS_API_KEY"
  5. 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