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
- The SDK sends a
POSTrequest with your text, model, and voice tohttps://tts.shunyalabs.ai/v1/audio/speech. - The server synthesizes the audio using the specified voice and model.
- A complete audio file is returned in the requested format (default: MP3).
- The SDK wraps the response in a
TTSResultobject with.save(),.audio_data, and metadata.