GEMINI LABJP
FLASH36 — Gemini 3.6 Flash, shipped July 21, uses about 17% fewer output tokens than 3.5 Flash at a lower price, with fewer stray code edits and execution loopsCYBER — Gemini 3.5 Flash Cyber is a lightweight model focused on finding, validating, and patching vulnerabilitiesCOMPUTER — Computer use is now available as a built-in client-side tool through the Gemini API and Gemini EnterpriseSPARK — Gemini Spark began rolling out in Japanese on July 16, starting with Google AI Ultra subscribersPARALLEL — Spark now processes multiple reference sources in parallel, and handles a wider range of image edits across Docs, Sheets, and SlidesSTUDENT — Students 18 and older in four countries, Japan included, get a free upgrade to Google AI Pro with NotebookLM and 2TB of storageFLASH36 — Gemini 3.6 Flash, shipped July 21, uses about 17% fewer output tokens than 3.5 Flash at a lower price, with fewer stray code edits and execution loopsCYBER — Gemini 3.5 Flash Cyber is a lightweight model focused on finding, validating, and patching vulnerabilitiesCOMPUTER — Computer use is now available as a built-in client-side tool through the Gemini API and Gemini EnterpriseSPARK — Gemini Spark began rolling out in Japanese on July 16, starting with Google AI Ultra subscribersPARALLEL — Spark now processes multiple reference sources in parallel, and handles a wider range of image edits across Docs, Sheets, and SlidesSTUDENT — Students 18 and older in four countries, Japan included, get a free upgrade to Google AI Pro with NotebookLM and 2TB of storage
Articles/API / SDK
API / SDK/2026-04-02Intermediate

Gemini TTS API: Generate Expressive Voice with Style Controls

A comprehensive guide to using the Gemini 2.5 Flash and Pro Text-to-Speech API. Learn how to specify voice styles, handle multi-speaker audio, and control tone and emotion through prompts — with practical code examples.

Gemini TTS2Text to SpeechVoice GenerationGemini API195Speech Synthesis

What is Gemini TTS?

Gemini TTS (Text-to-Speech) API is Google's official service that converts text into natural-sounding speech. Available on Gemini 2.5 Flash and Pro, it stands out by allowing you to specify styles and emotions, generating expressive audio rather than robotic speech.

How Gemini TTS Differs from Traditional TTS

Traditional text-to-speech services (like Google Cloud TTS) concatenate pre-recorded audio samples, offering high quality but limited expressiveness. Gemini TTS, powered by generative AI, lets you control style and emotion through prompts—resulting in human-like, flexible voice output.

Common Use Cases

  • Podcast Production — Create multiple character voices
  • Video Narration — Auto-narrate YouTube and TikTok content
  • Game Development — Dynamically generate character dialogue
  • Accessibility — Audio content for visually impaired users
  • Language Learning — Pronunciation guides and pronunciation practice

Core Specifications of Gemini TTS

Supported Models

  • Gemini 2.5 Flash — Fast, cost-effective (recommended)
  • Gemini 2.0 Pro — Higher-quality output

Available Voice Types

Gemini TTS offers multiple voice options trained from diverse speakers:

  • Breeze — Neutral, suited for announcements
  • Melody — Warm, conversational tone
  • Sage — Calm, speaker-like quality
  • Ember — Emotional, storytelling tone
  • Juniper — High-energy, kid-friendly
  • Orbit — Deep, cinematic narration

Pricing

  • Gemini 2.5 Flash: $1 per 1 million characters (audio output)
  • Gemini 2.0 Pro: $2 per 1 million characters
  • Free Tier: Up to 1,000 requests/month

API Setup and Basic Usage

Step 1: Obtain a Gemini API Key

Visit Google AI Studio and create an API key.

# Set environment variable
export GEMINI_API_KEY="YOUR_GEMINI_API_KEY"

Step 2: Install Python Library

pip install google-generativeai

Step 3: Minimal Code Example

import google.generativeai as genai
 
genai.configure(api_key="YOUR_GEMINI_API_KEY")
 
# Convert text to speech
response = genai.GenerativeModel(
    model_name="gemini-2.5-flash",
    system_prompt="You are a voice actor with expertise in audio narration."
).generate_content(
    genai.Part.from_data(
        mime_type="text/plain",
        data="Hello, world! This is a test of Gemini TTS."
    )
)
 
# Save as audio file
with open("output.mp3", "wb") as f:
    f.write(response.parts[0].inline_data.data)

Controlling Voice Style and Tone

Using Prompts to Set Emotion

The true power of Gemini TTS lies in prompt-based control. You can specify detailed emotional and tonal characteristics for your generated speech.

Example 1: Casual Friendly Conversation

style_prompt = """
Generate speech for a friendly conversation between friends.
Tone: Warm, approachable, slightly enthusiastic.
Speaking style: Casual, conversational, like chatting over coffee.
Text: "Hey! I just finished this amazing article about AI.
You've got to check it out when you have time!"
"""
 
response = genai.GenerativeModel("gemini-2.5-flash").generate_content(style_prompt)

Example 2: Professional Presentation

style_prompt = """
Generate speech for a professional presentation.
Tone: Confident, authoritative, measured.
Speaking style: Formal yet engaging, with natural pauses.
Text: "Today, we'll explore the fundamental principles of machine learning,
and how they're transforming industries worldwide."
"""

Example 3: Dramatic Storytelling

style_prompt = """
Generate speech for dramatic storytelling.
Tone: Emotional, dramatic, engaging.
Speaking style: Expressive, with dynamic energy shifts.
Pacing: Variable - slower for emotional moments, faster for action.
Text: "The sun set over the horizon as she realized everything had changed.
In that moment, she understood what she had to do."
"""

Fine-tuning with Audio Parameters

Fine-tune output with these parameters:

  • speed: 0.5 to 2.0 (slow to fast)
  • pitch: -10.0 to 10.0 (low to high)
  • volume_gain_db: -16.0 to 16.0 (quiet to loud)
response = genai.GenerativeModel("gemini-2.5-flash").generate_content(
    genai.Part.from_data(
        mime_type="application/json",
        data={
            "text": "Your narration text here",
            "voice_config": {
                "pitch": 0.0,
                "speaking_rate": 1.0,
                "volume_gain_db": 0.0
            }
        }
    )
)

Multi-Speaker TTS

For conversational content (podcasts, radio dramas), switching between speakers is essential.

Setting Speaker Labels

multi_speaker_text = """
Host: Welcome to AI Talk Podcast! Today's guest is an AI researcher.
 
Guest: Thank you for having me! I'm excited to share what we've learned.
 
Host: Let's dive in. What's the biggest misconception about AI?
 
Guest: People often think AI can reason like humans, but...
"""
 
# Generate audio for each speaker separately
host_audio = generate_tts(multi_speaker_text, speaker="host", style="warm")
guest_audio = generate_tts(multi_speaker_text, speaker="guest", style="authoritative")
 
# Mix audio tracks
merge_audio(host_audio, guest_audio, output_file="podcast.mp3")

Practical Use Cases

Use Case 1: Podcast Production

Automatically narrate scripts with multiple speakers, then add background music and sound effects for complete podcast automation.

Use Case 2: Video Narration

Auto-narrate YouTube and TikTok content with professional-quality voices. Reduces video production time by 90%.

Use Case 3: Game Development

Generate character dialogue in real-time, supporting dynamic storyline branching with natural voice acting.

Common Errors and Solutions

Error 1: "API quota exceeded"

Cause: Monthly request limit reached
Solution: Upgrade from Free Tier to a paid plan, or distribute usage across months

Error 2: "Invalid audio format"

Cause: Output format not MP3/WAV, or incorrect bitrate
Solution: Use PCM or MP3 (128kbps or higher), convert with ffmpeg if needed

Error 3: Long text generation failure

Cause: Single request exceeds 5,000 characters
Solution: Split text into chunks and make multiple API calls

Wrapping up

Gemini TTS API is a powerful tool for converting text into human-sounding speech. Its key strengths are flexible prompt-based expression control, multi-speaker support, and affordable pricing. Whether you're creating podcasts, narrating videos, or developing games, Gemini TTS enables new possibilities for audio content creation.

Get your API key today and start with "Hello, world!"


Reference Books: AI and Machine Learning Engineer's Implementation Guide (O'Reilly)

Share

Thank You for Reading

Gemini Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

If you found this article helpful, a small tip ($1.50) would mean a lot to us. Your support helps keep this site ad-free and covers server and hosting costs.

Related Articles

API / SDK2026-07-19
Run Managed Agents with background: true So Your UI Never Freezes — An Async Run Pattern for Solo Developers
A background run in Managed Agents returns a run ID, not a finished answer. Here is the minimal polling setup, where it pays off in solo development, and the credential-refresh details worth knowing.
API / SDK2026-07-19
Still image or short clip? Deciding feature placement from the cost gap between Nano Banana 2 Lite and Omni Flash
When I froze over whether a wallpaper app's hero asset should be a still image or a short moving loop, the deciding factor was not taste but the order of magnitude of the cost. Here is how to normalize Nano Banana 2 Lite and Omni Flash onto the same footing, down to a working decision function.
API / SDK2026-07-18
Keeping a Long-Running Managed Agent Alive Across Sandbox Recycling — Durable Checkpoints and Idempotent Resume
A Managed Agents sandbox can be recycled out from under you. Before 40 minutes of work resets to zero, we design a durable checkpoint that pushes progress outside the sandbox and an idempotent resume that never runs a side effect twice. With working SQLite code.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →