> For the complete documentation index, see [llms.txt](https://docs.cortecs.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cortecs.ai/usage/text-to-speech-beta.md).

# Text to Speech \[BETA]

{% hint style="warning" %}
This endpoint is currently in beta. For any issues or feedback, please contact us via [Discord](https://discord.com/invite/bPFEFcWBhp) or <support@cortecs.ai>.
{% endhint %}

**Text-to-Speech (TTS)** converts written text into natural-sounding audio, enabling applications such as voice assistants, audiobook generation, accessibility tools, and real-time speech synthesis. It supports multiple voices and providers, allowing flexible audio generation tailored to different use cases.

To explore available models, visit [cortecs.ai](https://cortecs.ai/serverlessModels?tags=Speech) and filter by the **Speech** tag.

### Example usage

{% tabs %}
{% tab title="Python" %}

```python
from openai import OpenAI 

client = OpenAI( 
    base_url="https://api.cortecs.ai/v1", 
    api_key="<API_KEY>", 
) 

response = client.audio.speech.create( 
    model="chatterbox-turbo", 
    input="Hello, this is a text-to-speech test.", 
    voice="<provider_voice>" 
) 

response.stream_to_file("speech.mp3")
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
import OpenAI from "openai";
import fs from "fs";

const openai = new OpenAI({
    baseURL: 'https://api.cortecs.ai/v1',
    apiKey: '<API_KEY>'
});

const response = await openai.audio.speech.create({
  model: "chatterbox-turbo",
  input: "Hello, this is a text-to-speech test.",
  voice: "<provider_voice>"
});

const buffer = Buffer.from(await response.arrayBuffer());
await fs.promises.writeFile("speech.mp3", buffer);
```

{% endtab %}

{% tab title="Curl" %}

```bash
curl 'https://api.cortecs.ai/v1/audio/speech' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <API_KEY>' \
  -d '{
    "model": "chatterbox-turbo",
    "input": "Hello, this is a text-to-speech test.",
    "voice": "<provider_voice>"
  }' \
  --output speech.mp3
```

{% endtab %}
{% endtabs %}

### **Voice Support**

Each provider supports different voice styles. Available options depend on the selected provider.

| Provider | Example Voice           |
| -------- | ----------------------- |
| Mistral  | `en_paul_neutral`       |
| Tensorix | `Emily.wav`             |
| OVH      | `"English-US.Female-1"` |

These are only example voices. Each provider may offer additional voice options depending on the model and configuration. Always check the provider documentation for the full list of available voices.

{% hint style="info" %}
Text-to-Speech models are priced **per character** of input text.
{% endhint %}
