Streaming TTS

Streaming to a File

Use the convenience method to stream audio directly to a file on disk.


Example

The stream_to_file() method handles chunk collection and file writing for you.

ShunyaLabs Python SDK
await client.tts.stream_to_file(
    "Hello! This is a streaming TTS example from ShunyaLabs",
    "chapter_01.pcm",
    config=TTSConfig(model="zero-indic", voice="Varun", response_format="pcm"),
)

Details

  • Audio is written incrementally as chunks arrive, keeping memory usage low.
  • The file is created (or overwritten) at the specified path.
  • Ideal for long-form content like audiobooks or podcast episodes.
  • Supports all output formats: pcm, mp3, wav, mulaw, ogg_opus.