SPB Git

Repository Public

speech-generation.md 30.3 KB 822 lines markdown

1<br />23# Text-to-speech generation (TTS)45> [!NOTE]6> **Note** : This version of the page covers the new [Interactions API](https://ai.google.dev/gemini-api/docs/interactions/interactions-overview), which is currently in Beta.  7> For stable production deployments, we recommend you continue to use the `generateContent` API. You can use the toggle on this page to switch between the versions.89The Gemini API can transform text input into single speaker or multi-speaker10audio using Gemini text-to-speech (TTS) generation capabilities.11Text-to-speech (TTS) generation is *[controllable](https://ai.google.dev/gemini-api/docs/interactions/speech-generation#controllable)* ,12meaning you can use natural language to structure interactions and guide the13*style* , *accent* , *pace* , and *tone* of the audio.1415The TTS capability differs from speech generation provided through the16[Live API](https://ai.google.dev/gemini-api/docs/live), which is designed for interactive,17unstructured audio, and multimodal inputs and outputs. While the Live API excels18in dynamic conversational contexts, TTS through the Gemini API19is tailored for scenarios that require exact text recitation with fine-grained20control over style and sound, such as podcast or audiobook generation.2122This guide shows you how to generate single-speaker and multi-speaker audio from23text.2425> [!WARNING]26> **Preview:** Gemini text-to-speech (TTS) is in [Preview](https://ai.google.dev/gemini-api/docs/models#preview).2728## Before you begin2930Ensure you use a Gemini 2.5 model variant with Gemini text-to-speech (TTS)31capabilities, as listed in the [Supported models](https://ai.google.dev/gemini-api/docs/interactions/speech-generation#supported-models)32section. For optimal results, consider which model best fits your specific33use case.3435You may find it useful to \[test the Gemini 2.5 TTS models in AI Studio\]3637> [!NOTE]38> **Note:** TTS models accept text-only inputs and produce audio-only outputs. For a complete list of restrictions specific to TTS models, review the [Limitations](https://ai.google.dev/gemini-api/docs/interactions/speech-generation#limitations) section.3940## Single-speaker TTS4142To convert text to single-speaker audio, set the response modality to "audio",43and pass a `speech_config` object with a voice name.44You'll need to choose a voice name from the prebuilt [output voices](https://ai.google.dev/gemini-api/docs/interactions/speech-generation#voices).4546This example saves the output audio from the model in a wave file:4748### Python4950    from google import genai51    import wave52    import base645354    def wave_file(filename, pcm, channels=1, rate=24000, sample_width=2):55        with wave.open(filename, "wb") as wf:56            wf.setnchannels(channels)57            wf.setsampwidth(sample_width)58            wf.setframerate(rate)59            wf.writeframes(pcm)6061    client = genai.Client()6263    interaction = client.interactions.create(64        model="gemini-3.1-flash-tts-preview",65        input="Say cheerfully: Have a wonderful day!",66        response_format={"type": "audio"},67        generation_config={68            "speech_config": [69                {"voice": "Kore"}70            ]71        }72    )7374    wave_file('out.wav', base64.b64decode(interaction.output_audio.data))7576### JavaScript7778    import {GoogleGenAI} from '@google/genai';79    import wav from 'wav';8081    async function saveWaveFile(82       filename,83       pcmData,84       channels = 1,85       rate = 24000,86       sampleWidth = 2,87    ) {88       return new Promise((resolve, reject) => {89          const writer = new wav.FileWriter(filename, {90                channels,91                sampleRate: rate,92                bitDepth: sampleWidth * 8,93          });9495          writer.on('finish', resolve);96          writer.on('error', reject);9798          writer.write(pcmData);99          writer.end();100       });101    }102103    async function main() {104       const client = new GoogleGenAI({});105106       const interaction = await client.interactions.create({107          model: "gemini-3.1-flash-tts-preview",108          input: "Say cheerfully: Have a wonderful day!",109          response_format: { type: 'audio' },110          generation_config: {111             speech_config: [112                { voice: 'Kore' }113             ]114          },115        });116117       const audioBuffer = Buffer.from(interaction.output_audio.data, 'base64');118119       await saveWaveFile('out.wav', audioBuffer);120    }121    await main();122123### REST124125    curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \126      -H "x-goog-api-key: $GEMINI_API_KEY" \127      -H "Content-Type: application/json" \128      -H "Api-Revision: 2026-05-20" \129      -d '{130         "model": "gemini-3.1-flash-tts-preview",131         "input": "Say cheerfully: Have a wonderful day!",132         "response_format": {133           "type": "audio"134         },135         "generation_config": {136           "speech_config": [137             { "voice": "Kore" }138           ]139         }140      }'141142You can retrieve generated audio data by using the `interaction.output_audio`143property, which returns the last generated audio block. For details on144convenience properties, see the145[Interactions overview](https://ai.google.dev/gemini-api/docs/interactions#convenience-properties).146147## Multi-speaker TTS148149For multi-speaker audio, you'll need a `multi_speaker_voice_config` object with150each speaker (up to 2) configured as a `speaker_voice_config`.151You'll need to define each `speaker` with the same names used in the152[prompt](https://ai.google.dev/gemini-api/docs/interactions/speech-generation#controllable):153154### Python155156    from google import genai157    import wave158    import base64159160    def wave_file(filename, pcm, channels=1, rate=24000, sample_width=2):161       with wave.open(filename, "wb") as wf:162          wf.setnchannels(channels)163          wf.setsampwidth(sample_width)164          wf.setframerate(rate)165          wf.writeframes(pcm)166167    client = genai.Client()168169    prompt = """TTS the following conversation between Joe and Jane:170             Joe: How's it going today Jane?171             Jane: Not too bad, how about you?"""172173     interaction = client.interactions.create(174         model="gemini-3.1-flash-tts-preview",175         input=prompt,176         response_format={"type": "audio"},177         generation_config={178             "speech_config": [179                 {"speaker": "Joe", "voice": "Kore"},180                 {"speaker": "Jane", "voice": "Puck"}181             ]182         }183     )184185    wave_file('out.wav', base64.b64decode(interaction.output_audio.data))186187### JavaScript188189    import {GoogleGenAI} from '@google/genai';190    import wav from 'wav';191192    async function saveWaveFile(193       filename,194       pcmData,195       channels = 1,196       rate = 24000,197       sampleWidth = 2,198    ) {199       return new Promise((resolve, reject) => {200          const writer = new wav.FileWriter(filename, {201                channels,202                sampleRate: rate,203                bitDepth: sampleWidth * 8,204          });205206          writer.on('finish', resolve);207          writer.on('error', reject);208209          writer.write(pcmData);210          writer.end();211       });212    }213214    async function main() {215       const client = new GoogleGenAI({});216217       const prompt = `TTS the following conversation between Joe and Jane:218             Joe: How's it going today Jane?219             Jane: Not too bad, how about you?`;220221       const interaction = await client.interactions.create({222          model: "gemini-3.1-flash-tts-preview",223          input: prompt,224          response_format: { type: 'audio' },225          generation_config: {226             speech_config: [227                { speaker: 'Joe', voice: 'Kore' },228                { speaker: 'Jane', voice: 'Puck' }229             ]230          },231       });232233       const audioBuffer = Buffer.from(interaction.output_audio.data, 'base64');234235       await saveWaveFile('out.wav', audioBuffer);236    }237238    await main();239240### REST241242    curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \243      -H "x-goog-api-key: $GEMINI_API_KEY" \244      -H "Content-Type: application/json" \245      -H "Api-Revision: 2026-05-20" \246      -d '{247      "model": "gemini-3.1-flash-tts-preview",248      "input": "TTS the following conversation between Joe and Jane: Joe: Hows it going today Jane? Jane: Not too bad, how about you?",249      "response_format": { "type": "audio" },250      "generation_config": {251        "speech_config": [252          { "speaker": "Joe", "voice": "Kore" },253          { "speaker": "Jane", "voice": "Puck" }254        ]255      }256    }'257258## Streaming speech generation259260You can stream the generated audio as it is being generated by the model by setting `stream: true`.261262> [!NOTE]263> **Note:** Streaming is supported for Text-to-Speech (TTS) models starting with version 3.1 (including `gemini-3.1-flash-tts-preview`).264265### Python266267    from google import genai268    import base64269270    client = genai.Client()271272    stream = client.interactions.create(273        model="gemini-3.1-flash-tts-preview",274        input="Say cheerfully: Have a wonderful day!",275        response_format={"type": "audio"},276        generation_config={277            "speech_config": [278                {"voice": "Kore"}279            ]280        },281        stream=True282    )283284    for event in stream:285        if event.event_type == "step.delta":286            if event.delta.type == "audio":287                audio_data = base64.b64decode(event.delta.data)288                # Process the audio chunk (e.g. play it or write to a file)289290### JavaScript291292    import {GoogleGenAI} from '@google/genai';293294    async function main() {295       const client = new GoogleGenAI({});296297       const stream = await client.interactions.create({298          model: "gemini-3.1-flash-tts-preview",299          input: "Say cheerfully: Have a wonderful day!",300          response_format: { type: 'audio' },301          generation_config: {302             speech_config: [303                { voice: 'Kore' }304             ]305          },306          stream: true307       });308309       for await (const event of stream) {310          if (event.event_type === 'step.delta') {311             if (event.delta.type === 'audio') {312                const audioBuffer = Buffer.from(event.delta.data, 'base64');313                // Process the audio buffer314             }315          }316       }317    }318    await main();319320### REST321322    curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \323      -H "x-goog-api-key: $GEMINI_API_KEY" \324      -H "Content-Type: application/json" \325      -H "Api-Revision: 2026-05-20" \326      --no-buffer \327      -d '{328        "model": "gemini-3.1-flash-tts-preview",329        "input": "Say cheerfully: Have a wonderful day!",330        "response_format": {331          "type": "audio"332        },333        "generation_config": {334          "speech_config": [335            { "voice": "Kore" }336          ]337        },338        "stream": true339      }'340341## Control speech style with prompts342343You can control style, tone, accent, and pace using natural language prompts344for both single- and multi-speaker TTS.345For example, in a single-speaker prompt, you can say:346347    Say in an spooky whisper:348    "By the pricking of my thumbs...349    Something wicked this way comes"350351In a multi-speaker prompt, provide the model with each speaker's name and352corresponding transcript. You can also provide guidance for each speaker353individually:354355    Make Speaker1 sound tired and bored, and Speaker2 sound excited and happy:356357    Speaker1: So... what's on the agenda today?358    Speaker2: You're never going to guess!359360Try using a [voice option](https://ai.google.dev/gemini-api/docs/interactions/speech-generation#voices) that corresponds to the style or emotion you361want to convey, to emphasize it even more. In the previous prompt, for example,362*Enceladus* 's breathiness might emphasize "tired" and "bored", while363*Puck*'s upbeat tone could complement "excited" and "happy".364365> [!TIP]366> **Tip:** The \[Voice Library\] applet in Google AI Studio is a great way to try out speech styles and voices with Gemini TTS.367368## Generate a prompt to convert to audio369370The TTS models only output audio, but you can use371[other models](https://ai.google.dev/gemini-api/docs/models) to generate a transcript first,372then pass that transcript to the TTS model to read aloud.373374### Python375376    from google import genai377378    client = genai.Client()379380    transcript_interaction = client.interactions.create(381       model="gemini-3.5-flash",382       input="""Generate a short transcript around 100 words that reads383                like it was clipped from a podcast by excited herpetologists.384                The hosts names are Dr. Anya and Liam."""385    )386    transcript = transcript_interaction.output_text387388    tts_interaction = client.interactions.create(389       model="gemini-3.1-flash-tts-preview",390       input=transcript,391       response_format={"type": "audio"},392       generation_config={393          "speech_config": [394             {"speaker": "Dr. Anya", "voice": "Kore"},395             {"speaker": "Liam", "voice": "Puck"}396          ]397       }398    )399400### JavaScript401402    import { GoogleGenAI } from "@google/genai";403404    const client = new GoogleGenAI({});405406    async function main() {407408    const transcriptInteraction = await client.interactions.create({409       model: "gemini-3.5-flash",410       input: "Generate a short transcript around 100 words that reads like it was clipped from a podcast by excited herpetologists. The hosts names are Dr. Anya and Liam.",411       })412413    const ttsInteraction = await client.interactions.create({414       model: "gemini-3.1-flash-tts-preview",415       input: transcriptInteraction.output_text,416       response_format: { type: 'audio' },417       generation_config: {418          speech_config: [419             { speaker: "Dr. Anya", voice: "Kore" },420             { speaker: "Liam", voice: "Puck" }421          ]422       }423      });424    }425426    await main();427428## Voice options429430TTS models support the following 30 voice options in the `voice_name` field:431432|---|---|---|433| **Zephyr** -- *Bright* | **Puck** -- *Upbeat* | **Charon** -- *Informative* |434| **Kore** -- *Firm* | **Fenrir** -- *Excitable* | **Leda** -- *Youthful* |435| **Orus** -- *Firm* | **Aoede** -- *Breezy* | **Callirrhoe** -- *Easy-going* |436| **Autonoe** -- *Bright* | **Enceladus** -- *Breathy* | **Iapetus** -- *Clear* |437| **Umbriel** -- *Easy-going* | **Algieba** -- *Smooth* | **Despina** -- *Smooth* |438| **Erinome** -- *Clear* | **Algenib** -- *Gravelly* | **Rasalgethi** -- *Informative* |439| **Laomedeia** -- *Upbeat* | **Achernar** -- *Soft* | **Alnilam** -- *Firm* |440| **Schedar** -- *Even* | **Gacrux** -- *Mature* | **Pulcherrima** -- *Forward* |441| **Achird** -- *Friendly* | **Zubenelgenubi** -- *Casual* | **Vindemiatrix** -- *Gentle* |442| **Sadachbia** -- *Lively* | **Sadaltager** -- *Knowledgeable* | **Sulafat** -- *Warm* |443444You can hear all the voice options in445446## Supported languages447448The TTS models detect the input language automatically. The following languages449are supported:450451| Language | BCP-47 Code | Language | BCP-47 Code |452|---|---|---|---|453| Arabic | ar | Filipino | fil |454| Bangla | bn | Finnish | fi |455| Dutch | nl | Galician | gl |456| English | en | Georgian | ka |457| French | fr | Greek | el |458| German | de | Gujarati | gu |459| Hindi | hi | Haitian Creole | ht |460| Indonesian | id | Hebrew | he |461| Italian | it | Hungarian | hu |462| Japanese | ja | Icelandic | is |463| Korean | ko | Javanese | jv |464| Marathi | mr | Kannada | kn |465| Polish | pl | Konkani | kok |466| Portuguese | pt | Lao | lo |467| Romanian | ro | Latin | la |468| Russian | ru | Latvian | lv |469| Spanish | es | Lithuanian | lt |470| Tamil | ta | Luxembourgish | lb |471| Telugu | te | Macedonian | mk |472| Thai | th | Maithili | mai |473| Turkish | tr | Malagasy | mg |474| Ukrainian | uk | Malay | ms |475| Vietnamese | vi | Malayalam | ml |476| Afrikaans | af | Mongolian | mn |477| Albanian | sq | Nepali | ne |478| Amharic | am | Norwegian, Bokmål | nb |479| Armenian | hy | Norwegian, Nynorsk | nn |480| Azerbaijani | az | Odia | or |481| Basque | eu | Pashto | ps |482| Belarusian | be | Persian | fa |483| Bulgarian | bg | Punjabi | pa |484| Burmese | my | Serbian | sr |485| Catalan | ca | Sindhi | sd |486| Cebuano | ceb | Sinhala | si |487| Chinese, Mandarin | cmn | Slovak | sk |488| Croatian | hr | Slovenian | sl |489| Czech | cs | Swahili | sw |490| Danish | da | Swedish | sv |491| Estonian | et | Urdu | ur |492493## Supported models494495| Model | Single speaker | Multispeaker |496|---|---|---|497| [Gemini 3.1 Flash TTS Preview](https://ai.google.dev/gemini-api/docs/models/gemini-3.1-flash-tts-preview) | ✔️ | ✔️ |498| [Gemini 2.5 Flash Preview TTS](https://ai.google.dev/gemini-api/docs/models/gemini-2.5-flash-preview-tts) | ✔️ | ✔️ |499| [Gemini 2.5 Pro Preview TTS](https://ai.google.dev/gemini-api/docs/models/gemini-2.5-pro-preview-tts) | ✔️ | ✔️ |500501## Prompting guide502503The **Gemini Native Audio Generation Text-to-Speech (TTS)** model differentiates504itself from conventional TTS models by using a large language model that505knows ***not only what to say, but also how to say it***.506507You can think of an advanced prompt as a system instruction for the model to508follow. It's a way to give the model more context and control over the509performance.510511To unlock this capability, users can think of themselves as directors setting a512scene for a virtual voice talent to perform. To craft a prompt, we recommend513considering the following components: an **Audio Profile** that defines the514character's core identity and archetype; a **Scene description** that515establishes the physical environment and emotional "vibe"; and **Director's516Notes** that offer more precise performance guidance regarding style, accent and517pace control.518519By providing nuanced instructions such as a precise regional accent, specific520paralinguistic features (e.g. breathiness), or pacing, users can leverage the521model's context awareness to generate highly dynamic, natural and expressive522audio performances. For optimal performance, we recommend the **Transcript** and523directorial prompts align, *so that "who is saying it"* matches with *"what is524said"* and *"how it is being said."*525526The purpose of this guide is to offer fundamental direction and spark ideas when527developing audio experiences using Gemini TTS audio generation. We are excited528to witness what you create!529530### Audio tags531532Tags are inline modifiers like `[whispers]` or `[laughs]` that give you granular533control over the delivery. You can use them to change the tone, pace, and534emotional vibe of a line or section of the transcript. You can also use them to535add interjections and a few other non-verbal sounds to the performance, like536`[cough]`, `[sighs]` or `[gasp]`.537538There is no exhaustive list on what tags do and don't work, we recommend539experimenting with different emotions and expressions to see how the output540changes.541542If your transcript is not in English, for best results we recommend that you543still use English audio tags.544545**Be creative with audio tags**546547To show the kind of variability you can get with audio tags, here are a set of548examples that each say the same thing, but the delivery changes based on the549tags used.550551You can change the emphasis of the delivery by adding tags at the start of a552line to make the speaker excited, bored, or reluctant:553554- `[excitedly]` Hey there, I'm a new text to speech model, and I can say things in many different ways. How can I help you today?555- `[bored]` Hey there, I'm a new text to speech model...556- `[reluctantly]` Hey there, I'm a new text to speech model...557558Tags can also be used to change the pace of the delivery, or to combine pace559with emphasis:560561- `[very fast]` Hey there, I'm a new text to speech model...562- `[very slow]` Hey there, I'm a new text to speech model...563- `[sarcastically, one painfully slow word at a time]` Hey there, I'm a new text to speech model...564565You also have precise control over specific sections, meaning you can whisper566one part and shout another.567568- `[whispers]` Hey there, I'm a new text to speech model, `[shouting]` and I can say things in many different ways. `[whispers]` How can I help you today569570You can also experiment with any creative idea you want:571572- `[like a cartoon dog]` Hey there, I'm a new text to speech model...573- `[like dracula]` Hey there, I'm a new text to speech model...574575Commonly used tags include:576577|---|---|---|---|578| `[amazed]` | `[crying]` | `[curious]` | `[excited]` |579| `[sighs]` | `[gasp]` | `[giggles]` | `[laughs]` |580| `[mischievously]` | `[panicked]` | `[sarcastic]` | `[serious]` |581| `[shouting]` | `[tired]` | `[trembling]` | `[whispers]` |582583Tags give quick control over the delivery of your transcript. For even584more control, you can combine them with a context prompt to set the overall tone585and vibe of the performance.586587### Prompting structure588589A robust prompt ideally includes the following elements that come together to590craft a great performance:591592- **Audio Profile** - Establishes a persona for the voice, defining a character identity, archetype and any other characteristics like age, background etc.593- **Scene** - Sets the stage. Describes both the physical environment and the "vibe".594- **Director's Notes** - Performance guidance where you can break down which instructions are important for your virtual talent to take note of. Examples are style, breathing, pacing, articulation and accent.595- **Sample context** - Gives the model a contextual starting point, so your virtual actor enters the scene you set up naturally.596- **Transcript** - The text that the model will speak out. For best performance, remember that the transcript topic and writing style should correlate to the directions you are giving.597- **Audio tags** - Modifiers you can put into a transcript to change how that part of the text is delivered, such as `[whispers]` or `[shouting]`.598599> [!NOTE]600> **Note:** Have Gemini help you build your prompt, just give it a blank outline of the following format and ask it to sketch out a character for you.601602Example full prompt:603604    # AUDIO PROFILE: Jaz R.605    ## "The Morning Hype"606607    ## THE SCENE: The London Studio608    It is 10:00 PM in a glass-walled studio overlooking the moonlit London skyline,609    but inside, it is blindingly bright. The red "ON AIR" tally light is blazing.610    Jaz is standing up, not sitting, bouncing on the balls of their heels to the611    rhythm of a thumping backing track. Their hands fly across the faders on a612    massive mixing desk. It is a chaotic, caffeine-fueled cockpit designed to wake613    up an entire nation.614615    ### DIRECTOR'S NOTES616    Style:617    * The "Vocal Smile": You must hear the grin in the audio. The soft palate is618    always raised to keep the tone bright, sunny, and explicitly inviting.619    * Dynamics: High projection without shouting. Punchy consonants and elongated620    vowels on excitement words (e.g., "Beauuutiful morning").621622    Pace: Speaks at an energetic pace, keeping up with the fast music.  Speaks623    with A "bouncing" cadence. High-speed delivery with fluid transitions - no dead624    air, no gaps.625626    Accent: Jaz is from Brixton, London627628    ### SAMPLE CONTEXT629    Jaz is the industry standard for Top 40 radio, high-octane event promos, or any630    script that requires a charismatic Estuary accent and 11/10 infectious energy.631632    #### TRANSCRIPT633    Yes, massive vibes in the studio! You are locked in and it is absolutely634    popping off in London right now. If you're stuck on the tube, or just sat635    there pretending to work... stop it. Seriously, I see you. Turn this up!636    We've got the project roadmap landing in three, two... let's go!637638### Detailed Prompting Strategies639640Break down each element of the prompt as follows:641642#### Audio Profile643644Briefly describe the persona of the character.645646- **Name.** Giving your character a name helps ground the model and tight performance together, Refer to the character by name when setting the scene and context647- **Role.** Core identity and archetype of the character that's playing out in the scene. e.g., Radio DJ, Podcaster, News reporter etc.648649Examples:650651    # AUDIO PROFILE: Jaz R.652    ## "The Morning Hype"653654<br />655656    # AUDIO PROFILE: Monica A.657    ## "The Beauty Influencer"658659#### Scene660661Set the context for the scene, including location, mood, and environmental662details that establish the tone and vibe. Describe what is happening around the663character and how it affects them. The scene provides the environmental context664for the entire interaction and guides the acting performance in a subtle665organic way.666667Examples:668669    ## THE SCENE: The London Studio670    It is 10:00 PM in a glass-walled studio overlooking the moonlit London skyline,671    but inside, it is blindingly bright. The red "ON AIR" tally light is blazing.672    Jaz is standing up, not sitting, bouncing on the balls of their heels to the673    rhythm of a thumping backing track. Their hands fly across the faders on a674    massive mixing desk. It is a chaotic, caffeine-fueled cockpit designed to675    wake up an entire nation.676677<br />678679    ## THE SCENE: Homegrown Studio680    A meticulously sound-treated bedroom in a suburban home. The space is681    deadened by plush velvet curtains and a heavy rug, but there is a682    distinct "proximity effect."683684#### Directors notes685686This critical section includes specific performance guidance. You can skip all687the other elements, but we recommend you include this element.688689Define only what's important to the performance, being careful to not690overspecify. Too many strict rules will limit the models' creativity and may691result in a worse performance. Balance the role and scene description with the692specific performance rules.693694The most common directions are **Style, Pacing and Accent**, but the model is695not limited to these, nor requires them. Feel free to include custom696instructions to cover any additional details important to your performance, and697go into as much or as little detail as necessary.698699For example:700701    ### DIRECTOR'S NOTES702703    Style: Enthusiastic and Sassy GenZ beauty YouTuber704705    Pacing: Speaks at an energetic pace, keeping up with the extremely fast, rapid706    delivery influencers use in short form videos.707708    Accent: Southern california valley girl from Laguna Beach |709710**Style:**711712Sets the tone and Style of the generated speech. Include things like upbeat,713energetic, relaxed, bored etc. to guide the performance. Be descriptive and714provide as much detail as necessary: *"Infectious enthusiasm. The listener715should feel like they are part of a massive, exciting community event."* works716better than saying *"energetic and enthusiastic".*717718You can even try terms that are popular in the voiceover industry, like "vocal719smile". You can layer as many style characteristics as you want.720721Examples:722723Simple Emotion724725    DIRECTORS NOTES726    ...727    Style: Frustrated and angry developer who can't get the build to run.728    ...729730More depth731732    DIRECTORS NOTES733    ...734    Style: Sassy GenZ beauty YouTuber, who mostly creates content for YouTube Shorts.735    ...736737Complex738739    DIRECTORS NOTES740    Style:741    * The "Vocal Smile": You must hear the grin in the audio. The soft palate is742    always raised to keep the tone bright, sunny, and explicitly inviting.743    *Dynamics: High projection without shouting. Punchy consonants and744    elongated vowels on excitement words (e.g., "Beauuutiful morning").745746**Accent:**747748Describe the selected accent. The more specific you are, the better the749results are. For example use "*British English accent as heard in Croydon,750England* " versus "*British Accent*".751752Examples:753754    ### DIRECTORS NOTES755    ...756    Accent: Southern california valley girl from Laguna Beach757    ...758759<br />760761    ### DIRECTORS NOTES762    ...763    Accent: Jaz is a from Brixton, London764    ...765766**Pacing:**767768Overall pacing and pace variation throughout the piece.769770Examples:771772Simple773774    ### DIRECTORS NOTES775    ...776    Pacing: Speak as fast as possible777    ...778779More Depth780781    ### DIRECTORS NOTES782    ...783    Pacing: Speaks at a faster, energetic pace, keeping up with fast paced music.784    ...785786Complex787788    ### DIRECTORS NOTES789    ...790    Pacing: The "Drift": The tempo is incredibly slow and liquid. Words bleed into each other. There is zero urgency.791    ...792793**Give it a try**794795Try some of these examples yourself on796[TTS App](http://aistudio.google.com/app/apps/bundled/synergy_intro) and let797Gemini put you in the directors chair. Keep these tips in mind to make great798vocal performances:799800- Remember to keep the entire prompt coherent -- the script and direction go hand in hand in creating a great performance.801- Don't feel you have to describe everything, sometimes giving the model space to fill in the gaps helps naturalness. (Just like a talented actor)802- If you ever are feeling stuck, have Gemini lend you a hand to help you craft your script or performance.803804## Limitations805806- TTS models can only receive text inputs and generate audio outputs.807- A TTS session has a [context window](https://ai.google.dev/gemini-api/docs/long-context) limit of 32k tokens.808- Review [Languages](https://ai.google.dev/gemini-api/docs/interactions/speech-generation#languages) section for language support.809- TTS does not support streaming, except when using `gemini-3.1-flash-tts-preview`.810811The following constraints apply specifically when using the Gemini 3.1 Flash812TTS Preview model for speech generation:813814- **Voice inconsistency with prompt instructions:** The model's output may not always strictly match the selected speaker, causing the audio to sound different than expected. To avoid mismatched tones (such as a deep male voice attempting to speak like a young girl), ensure your prompt's written tone and context align naturally with the selected speaker's profile.815- **Quality of longer outputs:** Speech quality and consistency may begin to drift with generated outputs that are longer than a few minutes. We recommend splitting your transcripts into smaller chunks.816- **Occasional text token returns:** The model occasionally returns text tokens instead of audio tokens, causing the server to fail the request with a `500` error. Because this occurs randomly in a very small percentage of requests, you should implement automated retry logic in your application to handle these.817- **Prompt classifier false rejections:** Vague prompts may fail to trigger the speech synthesis classifier, resulting in a rejected request (`PROHIBITED_CONTENT`) or causing the model to read your style instructions and director's notes aloud. Validate your prompts by adding a clear preamble instructing the model to synthesize speech, and explicitly label where the actual spoken transcript begins.818819## What's next820821- Gemini's [Live API](https://ai.google.dev/gemini-api/docs/live) offers interactive audio generation options you can interleave with other modalities.822- For working with audio *inputs* , visit the [Audio understanding](https://ai.google.dev/gemini-api/docs/interactions/audio) guide.
Files main
Menu

Theme