Back to library
AI
best practice

Enable Instant Audio Playback with Streaming Text-to-Speech

Reduce latency by streaming generated speech content in your applications.

Implement streaming speech generation using the gemini-3.1-flash-tts-preview model to enable immediate audio playback for long-form text.

Google Gemini

The Scenario

You are building an application or tool that needs to read long passages of text aloud to a user in real-time without long buffering delays.

Before & after

The old way

Generating full speech files usually required the entire text to be processed before playback could begin, creating a 30-60 second wait for long documents.

With AI

With Gemini 3.1, you can use the streaming TTS preview to receive audio segments as they are generated. This allows the playback to start in under 5 seconds.

The Prompt

[DEVELOPER_CONTEXT] Set up a streaming text-to-speech request using the gemini-3.1-flash-tts-preview model to read the following text with low latency: [INSERT_TEXT]

Streaming via `streamGenerateContent` for the `gemini-3.1-flash-tts-preview` model significantly reduces the 'time to first byte' for audio applications. This is critical for developers building interactive voice bots or accessibility tools.

Source

Release notes  |  Gemini API  |  Google AI for Developers
"Streaming support for speech generation: Streaming via streamGenerateContent... is now supported for the gemini-3.1-flash-tts-preview model."