Generate audio from text
Voice
Generate Audio
Converts text to speech using AI-powered voices. Returns an audio stream in MP3 format.
POST
Generate audio from text
Converts text to speech using AI-powered voices. Returns an audio stream in MP3 format that can be played, downloaded, or integrated into applications.
Overview
The Text-to-Speech API allows you to generate natural-sounding speech from text in multiple languages and voices. This endpoint is useful for creating voice content, accessibility features, voice assistants, and more.Use Cases
- Voice Assistants: Generate spoken responses for chatbots and virtual assistants
- Accessibility: Create audio versions of text content for visually impaired users
- Content Creation: Produce voiceovers for videos, podcasts, or presentations
- E-Learning: Generate audio narration for educational materials
- IVR Systems: Create dynamic voice prompts for phone systems
Basic Usage
Voice Options
The API supports 12 different voices with various characteristics:| Voice Name | Gender | Best For |
|---|---|---|
| ALEX | Male | Professional, clear delivery |
| PETER | Male | Warm, conversational tone |
| MIRIAM | Female | Professional, authoritative |
| SUE | Female | Friendly, approachable |
| VIERA | Female | Clear, neutral tone |
| CASANDRA | Female | Warm, engaging |
| SILVIA | Female | Professional, polished |
| MICHAEL | Male | Deep, authoritative |
| LUKE | Male | Energetic, dynamic |
| EMMA | Female | Clear, friendly |
| SARAH | Female | Warm, professional |
| EVA | Female | Neutral, versatile |
Language Support
The API supports 33 languages. Use the appropriate language code for your text:| Language | Code | Language | Code | Language | Code |
|---|---|---|---|---|---|
| English | en | Japanese | ja | Chinese | zh |
| German | de | Hindi | hi | French | fr |
| Korean | ko | Portuguese | pt | Italian | it |
| Spanish | es | Indonesian | id | Dutch | nl |
| Turkish | tr | Filipino | fil | Polish | pl |
| Swedish | sv | Bulgarian | bg | Romanian | ro |
| Arabic | ar | Czech | cs | Greek | el |
| Finnish | fi | Croatian | hr | Malay | ms |
| Slovak | sk | Danish | da | Tamil | ta |
| Ukrainian | uk | Russian | ru | Hungarian | hu |
| Norwegian | no | Vietnamese | vi |
Response Format
The endpoint returns an audio stream withContent-Type: audio/mpeg. You can:
- Stream directly: Play the audio in real-time
- Save to file: Download and store the MP3 file
- Integrate: Use in applications, websites, or phone systems
Example: Saving Audio (Node.js)
Example: Playing Audio (Browser)
Example: Python
Text Limitations
The
text field has a maximum length of 5,000 characters. For longer content, split the text into multiple requests.Authentication & Scopes
Error Handling
Common errors you may encounter:- 400 Bad Request: Invalid voice name or language code
- 401 Unauthorized: Missing or invalid API key
- 403 Forbidden: API key lacks VOICE scope
- 413 Payload Too Large: Text exceeds 5,000 characters
- 429 Too Many Requests: Rate limit exceeded
Rate Limiting
This endpoint is subject to your API key’s rate limits. Monitor the rate limit headers in the response:X-RateLimit-Limit: Maximum requests allowedX-RateLimit-Remaining: Requests remaining in current windowX-RateLimit-Reset: Time when the rate limit resets
Related Resources
API Keys Guide
Learn about API key management and scopes
Rate Limiting
Understand rate limits and best practices
Error Handling
Handle API errors gracefully
Scopes & Permissions
Learn about API key scopes
Authorizations
API key for authentication using Bearer scheme
Query Parameters
Required for ATS API keys to specify which company to access. Ignored for standard company API keys.
Body
application/json
The text to convert to speech
Maximum string length:
5000Example:
"Hello, this is a test."
The voice name to use for generation
Available options:
ALEX, PETER, MIRIAM, SUE, VIERA, CASANDRA, SILVIA, MICHAEL, LUKE, EMMA, SARAH, EVA Example:
"ALEX"
The language of the text
Available options:
en, ja, zh, de, hi, fr, ko, pt, it, es, id, nl, tr, fil, pl, sv, bg, ro, ar, cs, el, fi, hr, ms, sk, da, ta, uk, ru, hu, no, vi Example:
"en"
Response
Audio stream generated successfully
The response is of type file.