> ## Documentation Index
> Fetch the complete documentation index at: https://docs.geekai.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Convert text to speech

### Quick start

Supported text-to-speech models include `tts-1`, `tts-1-hd`, `gpt-4o-mini-tts`, `doubao-tts`, and `seed-tts-1.1`. Send text in the `input` field:

```bash theme={null}
curl --location 'https://geekai.co/api/v1/audio/speech' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $GEEKAI_API_KEY" \
--data '{
    "input":"Hello! Nice to meet you!",
    "model":"gpt-4o-mini-tts"
}'
```

Doubao speech synthesis supports Chinese and English only. For other languages, use an OpenAI speech model.

### Voices

OpenAI supports the following values for `voice`:

* alloy
* ash
* ballad
* coral
* echo
* fable
* onyx
* nova
* sage
* shimmer

Set `voice` to the name of the voice you want.

Doubao has a larger voice catalog. Choose a `voice_type` from [Volcengine's speech synthesis voice list](https://www.volcengine.com/docs/6561/1257544) and pass it as `voice`.

### Audio formats

Set `response_format` to one of these OpenAI output formats:

* `mp3`
* `opus`
* `wav`
* `flac`
* `pcm`
* `aac`

The default format is `mp3`. Doubao supports `mp3`, `wav`, `pcm`, and `ogg_opus` only.

### Streaming output

By default, the response is a binary audio file. To play audio as it arrives, set `stream_format` to `sse`. Streaming is supported by `gpt-4o-mini-tts`, `doubao-tts`, and `seed-tts-1.1`:

```bash theme={null}
curl --location 'https://geekai.co/api/v1/audio/speech' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $GEEKAI_API_KEY" \
--data '{
    "input":"Hello! Nice to meet you!",
    "model":"doubao-tts",
    "response_format":"pcm",
    "stream_format":"sse"
}'
```

> [!NOTE]
>
> For low-latency playback, use `pcm`. Doubao does not support streaming in `wav` format.

The server streams Base64-encoded audio in chunks using server-sent events. Read each event until you receive `[DONE]`. The format is compatible with OpenAI streaming speech synthesis.

An event with `type` set to `speech.audio.delta` contains a Base64-encoded audio fragment in `audio`. Decode and concatenate the fragments to save the file, or play them as you decode them:

```json theme={null}
{
    "id": "24f44c9a-e6f9-4a80-812a-d17e6621e107",
    "type": "speech.audio.delta",
    "audio": "<base64-encoded audio fragment>"
}
```

An event with `type` set to `speech.audio.done` marks the end of the audio. You can then close the event stream:

```json theme={null}
{
    "id": "24f44c9a-e6f9-4a80-812a-d17e6621e107",
    "type": "speech.audio.done",
    "usage": {
        "input_tokens": 3,
        "output_tokens": 73,
        "total_tokens": 76
    }
}
```

For additional speech synthesis parameters, see the [API reference](https://docs.geekai.co/en/api/audio/texttospeech.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.