> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Text To Speech

> Generate speech with a Gemini TTS model and write the audio to a WAV file.

```python text_to_speech.py theme={null}
"""
Google Text To Speech
=====================

Cookbook example for `google/gemini/text_to_speech.py`.
"""

from agno.agent import Agent
from agno.models.google import Gemini
from agno.utils.audio import write_wav_audio_to_file

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------

agent = Agent(
    model=Gemini(
        id="gemini-2.5-flash-preview-tts",
        response_modalities=["AUDIO"],
        speech_config={
            "voice_config": {"prebuilt_voice_config": {"voice_name": "Kore"}}
        },
    )
)

run_output = agent.run("Say cheerfully: Have a wonderful day!")

if run_output.response_audio is not None:
    audio_data = run_output.response_audio.content
    output_file = "tmp/cheerful_greeting.wav"
    write_wav_audio_to_file(output_file, audio_data)

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------

if __name__ == "__main__":
    pass
```

## Run the Example

<Snippet file="create-venv-step.mdx" />

**1. Install dependencies**

```bash theme={null}
uv pip install -U agno google-genai
```

**2. Export your Google API key**

```bash Mac/Linux theme={null}
export GOOGLE_API_KEY="your_google_api_key_here"
```

```bash Windows theme={null}
$Env:GOOGLE_API_KEY="your_google_api_key_here"
```

**3. Run the example**

Save the code above as `text_to_speech.py`, then run:

```bash theme={null}
python text_to_speech.py
```

Full source: [cookbook/90\_models/google/gemini/text\_to\_speech.py](https://github.com/agno-agi/agno/blob/v3.0.4/cookbook/90_models/google/gemini/text_to_speech.py)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.