🐍 Python Developer Guide
Python Text to Speech API Quickstart
Learn how to make HTTP requests to our Python text-to-speech API endpoints using Aura and Rapid models. Convert any text into high-fidelity AI audio in synchronous scripts or asynchronous microservices.
1. Prerequisites & API Key Setup
All API requests require your X-API-Key header. We recommend storing your credential in an environment variable (YOURVOIC_API_KEY):
2. Synchronous Speech Generation (`requests`)
The following Python code uses the requests library to send a POST payload to the REST endpoint and writes the binary MP3 stream directly to disk.
3. Asynchronous Speech Synthesis (`aiohttp`)
For high-concurrency Python applications (such as FastAPI, Sanic, or Discord bots), use aiohttp to avoid blocking the main event loop.
4. Python API Parameters Reference
| Parameter | Type | Description |
|---|---|---|
| text | string | The input text to convert into speech. |
| model | string | Model: rapid-flash, aura-lite, rapid-max, aura-prime, aura-max. |
| voice | string | Target voice name (e.g. Peter, Kylie, Rahul, Deepika). |
| language | string | Language code (e.g. en-US, hi-IN, es-ES). |
| format | string | Audio format: mp3 or wav. |
Explore Other Integrations & Documentation
Compare Python with JavaScript or read full REST API technical specs.