---
title: "Convert text to speech using a specified voice"
method: POST
path: "/v1/TextToSpeech"
---

# Convert text to speech using a specified voice

`POST /v1/TextToSpeech`

## Request

- Base URL: `https://api.musicgpt.com/api/public`
- URL: `https://api.musicgpt.com/api/public/v1/TextToSpeech`
- Auth: API key in header `Authorization`

Synthesize speech from text with voice and gender customization, plus optional webhook callback.  
Give priority to the sample audio first, then to the voice ID, and lastly to gender.

## Request body

- union
  - object
    - `text` string, required: Text to convert to speech
    - `voice_id` string: Voice model ID
    - `gender` string: Gender preference for the voice (e.g., "male", "female")
    - `sample_audio_url` string, required: An audio URL containing a voice sample of the target speaker without music or overlapping voices. Recommended over voice_id for better output quality.
    - `webhook_url` string: Callback URL for async processing
  - object
    - `text` string, required: Text to convert to speech
    - `voice_id` string, required: Voice model ID
    - `gender` string: Gender preference for the voice (e.g., "male", "female")
    - `sample_audio_url` string: An audio URL containing a voice sample of the target speaker without music or overlapping voices. Recommended over voice_id for better output quality.
    - `webhook_url` string: Callback URL for async processing

## Response `200`

Successfully initiated TTS conversion

- object
  - `success` boolean
  - `task_id` string
  - `conversion_id` string
  - `eta` integer

## Other responses

- `402`: Payment Required
- `422`: Validation Error
- `500`: Server Error

---

[API](https://skmtc.dev/musicgpt/apis/musicgpt-api.md) - [All operations](https://skmtc.dev/musicgpt/apis/musicgpt-api/llms.txt) - [OpenAPI document](https://skmtc.dev/musicgpt/apis/musicgpt-api/revisions/6753dccf4c5d?raw)
