Batch TTS

Your First Request

Generate audio from text in under five minutes using the ShunyaLabs Python SDK, REST API, or OpenAI-compatible client.


Code examples

ShunyaLabs Python SDK
import asyncio
from shunyalabs import AsyncShunyaClient
from shunyalabs.tts import TTSConfig

async def main():
    async with AsyncShunyaClient() as client:
        result = await client.tts.synthesize(
            "Hello, how are you today?",
            config=TTSConfig(model="zero-indic", voice="Varun"),
        )
        result.save("output.mp3")
        print(f"{len(result.audio_data)} bytes saved")

asyncio.run(main())

REST API — Python requests

Python (requests)
import requests

response = requests.post(
    "https://tts.shunyalabs.ai/v1/audio/speech",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={
        "model": "zero-indic",
        "input": "Hello, how are you today?",
        "voice": "Varun",
    },
    timeout=120,
)
response.raise_for_status()

with open("output.mp3", "wb") as f:
    f.write(response.content)

What happens under the hood

  1. The SDK sends a POST request with your text, model, and voice to https://tts.shunyalabs.ai/v1/audio/speech.
  2. The server synthesizes the audio using the specified voice and model.
  3. A complete audio file is returned in the requested format (default: MP3).
  4. The SDK wraps the response in a TTSResult object with .save(), .audio_data, and metadata.