音声生成(テキスト読み上げ)

Gemini API は、ネイティブのテキスト読み上げ(TTS)生成機能を使用して、テキスト入力を単一話者または複数話者の音声に変換できます。テキスト読み上げ(TTS)の生成は制御可能です。つまり、自然言語を使用してインタラクションを構成し、音声のスタイル、アクセント、ペース、トーンをガイドできます。

TTS 機能は、インタラクティブな非構造化音声とマルチモーダルな入力と出力用に設計された Live API を介して提供される音声生成とは異なります。Live API は動的な会話コンテキストに優れていますが、Gemini API を介した TTS は、ポッドキャストやオーディオブックの生成など、スタイルやサウンドを細かく制御してテキストを正確に朗読する必要があるシナリオ向けに調整されています。

このガイドでは、テキストから単一話者と複数話者の音声を生成する方法について説明します。

始める前に

サポートされているモデル セクションに記載されているように、ネイティブのテキスト読み上げ(TTS)機能を備えた Gemini 2.5 モデル バリアントを使用してください。最適な結果を得るには、特定のユースケースに最適なモデルを検討してください。

構築を開始する前に、AI Studio で Gemini 2.5 TTS モデルをテストすると便利です。

1 人の話し手のテキスト読み上げ

テキストを 1 人のスピーカーの音声に変換するには、レスポンス モダリティを「音声」に設定し、VoiceConfig を設定した SpeechConfig オブジェクトを渡します。事前構築済みの出力音声から音声名を選択する必要があります。

この例では、モデルからの出力音声を wave ファイルに保存します。

Python

from google import genai
from google.genai import types
import wave

# Set up the wave file to save the output:
def wave_file(filename, pcm, channels=1, rate=24000, sample_width=2):
   with wave.open(filename, "wb") as wf:
      wf.setnchannels(channels)
      wf.setsampwidth(sample_width)
      wf.setframerate(rate)
      wf.writeframes(pcm)

client = genai.Client()

response = client.models.generate_content(
   model="gemini-2.5-flash-preview-tts",
   contents="Say cheerfully: Have a wonderful day!",
   config=types.GenerateContentConfig(
      response_modalities=["AUDIO"],
      speech_config=types.SpeechConfig(
         voice_config=types.VoiceConfig(
            prebuilt_voice_config=types.PrebuiltVoiceConfig(
               voice_name='Kore',
            )
         )
      ),
   )
)

data = response.candidates[0].content.parts[0].inline_data.data

file_name='out.wav'
wave_file(file_name, data) # Saves the file to current directory

JavaScript

import {GoogleGenAI} from '@google/genai';
import wav from 'wav';

async function saveWaveFile(
   filename,
   pcmData,
   channels = 1,
   rate = 24000,
   sampleWidth = 2,
) {
   return new Promise((resolve, reject) => {
      const writer = new wav.FileWriter(filename, {
            channels,
            sampleRate: rate,
            bitDepth: sampleWidth * 8,
      });

      writer.on('finish', resolve);
      writer.on('error', reject);

      writer.write(pcmData);
      writer.end();
   });
}

async function main() {
   const ai = new GoogleGenAI({});

   const response = await ai.models.generateContent({
      model: "gemini-2.5-flash-preview-tts",
      contents: [{ parts: [{ text: 'Say cheerfully: Have a wonderful day!' }] }],
      config: {
            responseModalities: ['AUDIO'],
            speechConfig: {
               voiceConfig: {
                  prebuiltVoiceConfig: { voiceName: 'Kore' },
               },
            },
      },
   });

   const data = response.candidates?.[0]?.content?.parts?.[0]?.inlineData?.data;
   const audioBuffer = Buffer.from(data, 'base64');

   const fileName = 'out.wav';
   await saveWaveFile(fileName, audioBuffer);
}
await main();

REST

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-preview-tts:generateContent" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
        "contents": [{
          "parts":[{
            "text": "Say cheerfully: Have a wonderful day!"
          }]
        }],
        "generationConfig": {
          "responseModalities": ["AUDIO"],
          "speechConfig": {
            "voiceConfig": {
              "prebuiltVoiceConfig": {
                "voiceName": "Kore"
              }
            }
          }
        },
        "model": "gemini-2.5-flash-preview-tts",
    }' | jq -r '.candidates[0].content.parts[0].inlineData.data' | \
          base64 --decode >out.pcm
# You may need to install ffmpeg.
ffmpeg -f s16le -ar 24000 -ac 1 -i out.pcm out.wav

複数話者のテキスト読み上げ

マルチスピーカー オーディオの場合、各スピーカー(最大 2 つ)が SpeakerVoiceConfig として構成された MultiSpeakerVoiceConfig オブジェクトが必要です。各 speaker は、プロンプトで使用されている名前と同じ名前で定義する必要があります。

Python

from google import genai
from google.genai import types
import wave

# Set up the wave file to save the output:
def wave_file(filename, pcm, channels=1, rate=24000, sample_width=2):
   with wave.open(filename, "wb") as wf:
      wf.setnchannels(channels)
      wf.setsampwidth(sample_width)
      wf.setframerate(rate)
      wf.writeframes(pcm)

client = genai.Client()

prompt = """TTS the following conversation between Joe and Jane:
         Joe: How's it going today Jane?
         Jane: Not too bad, how about you?"""

response = client.models.generate_content(
   model="gemini-2.5-flash-preview-tts",
   contents=prompt,
   config=types.GenerateContentConfig(
      response_modalities=["AUDIO"],
      speech_config=types.SpeechConfig(
         multi_speaker_voice_config=types.MultiSpeakerVoiceConfig(
            speaker_voice_configs=[
               types.SpeakerVoiceConfig(
                  speaker='Joe',
                  voice_config=types.VoiceConfig(
                     prebuilt_voice_config=types.PrebuiltVoiceConfig(
                        voice_name='Kore',
                     )
                  )
               ),
               types.SpeakerVoiceConfig(
                  speaker='Jane',
                  voice_config=types.VoiceConfig(
                     prebuilt_voice_config=types.PrebuiltVoiceConfig(
                        voice_name='Puck',
                     )
                  )
               ),
            ]
         )
      )
   )
)

data = response.candidates[0].content.parts[0].inline_data.data

file_name='out.wav'
wave_file(file_name, data) # Saves the file to current directory

JavaScript

import {GoogleGenAI} from '@google/genai';
import wav from 'wav';

async function saveWaveFile(
   filename,
   pcmData,
   channels = 1,
   rate = 24000,
   sampleWidth = 2,
) {
   return new Promise((resolve, reject) => {
      const writer = new wav.FileWriter(filename, {
            channels,
            sampleRate: rate,
            bitDepth: sampleWidth * 8,
      });

      writer.on('finish', resolve);
      writer.on('error', reject);

      writer.write(pcmData);
      writer.end();
   });
}

async function main() {
   const ai = new GoogleGenAI({});

   const prompt = `TTS the following conversation between Joe and Jane:
         Joe: How's it going today Jane?
         Jane: Not too bad, how about you?`;

   const response = await ai.models.generateContent({
      model: "gemini-2.5-flash-preview-tts",
      contents: [{ parts: [{ text: prompt }] }],
      config: {
            responseModalities: ['AUDIO'],
            speechConfig: {
               multiSpeakerVoiceConfig: {
                  speakerVoiceConfigs: [
                        {
                           speaker: 'Joe',
                           voiceConfig: {
                              prebuiltVoiceConfig: { voiceName: 'Kore' }
                           }
                        },
                        {
                           speaker: 'Jane',
                           voiceConfig: {
                              prebuiltVoiceConfig: { voiceName: 'Puck' }
                           }
                        }
                  ]
               }
            }
      }
   });

   const data = response.candidates?.[0]?.content?.parts?.[0]?.inlineData?.data;
   const audioBuffer = Buffer.from(data, 'base64');

   const fileName = 'out.wav';
   await saveWaveFile(fileName, audioBuffer);
}

await main();

REST

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-preview-tts:generateContent" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
  "contents": [{
    "parts":[{
      "text": "TTS the following conversation between Joe and Jane:
                Joe: Hows it going today Jane?
                Jane: Not too bad, how about you?"
    }]
  }],
  "generationConfig": {
    "responseModalities": ["AUDIO"],
    "speechConfig": {
      "multiSpeakerVoiceConfig": {
        "speakerVoiceConfigs": [{
            "speaker": "Joe",
            "voiceConfig": {
              "prebuiltVoiceConfig": {
                "voiceName": "Kore"
              }
            }
          }, {
            "speaker": "Jane",
            "voiceConfig": {
              "prebuiltVoiceConfig": {
                "voiceName": "Puck"
              }
            }
          }]
      }
    }
  },
  "model": "gemini-2.5-flash-preview-tts",
}' | jq -r '.candidates[0].content.parts[0].inlineData.data' | \
    base64 --decode > out.pcm
# You may need to install ffmpeg.
ffmpeg -f s16le -ar 24000 -ac 1 -i out.pcm out.wav

プロンプトで話し方を制御する

単一話者と複数話者の両方の TTS で、自然言語プロンプトを使用してスタイル、トーン、アクセント、速度を制御できます。たとえば、1 人のスピーカーのプロンプトでは、次のように言います。

Say in an spooky whisper:
"By the pricking of my thumbs...
Something wicked this way comes"

複数話者のプロンプトでは、各話者の名前と対応する文字起こしをモデルに提供します。スピーカーごとに個別にガイダンスを提供することもできます。

Make Speaker1 sound tired and bored, and Speaker2 sound excited and happy:

Speaker1: So... what's on the agenda today?
Speaker2: You're never going to guess!

伝えたいスタイルや感情に対応する音声オプションを使用すると、さらに強調できます。たとえば、前のプロンプトでは、エンケラドゥスの息遣いが「疲れた」や「退屈」を強調し、パックの明るいトーンが「興奮した」や「幸せ」を補完する可能性があります。

音声に変換するプロンプトを生成しています

TTS モデルは音声のみを出力しますが、他のモデルを使用して最初に文字起こしを生成し、その文字起こしを TTS モデルに渡して読み上げることができます。

Python

from google import genai
from google.genai import types

client = genai.Client()

transcript = client.models.generate_content(
   model="gemini-2.0-flash",
   contents="""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.""").text

response = client.models.generate_content(
   model="gemini-2.5-flash-preview-tts",
   contents=transcript,
   config=types.GenerateContentConfig(
      response_modalities=["AUDIO"],
      speech_config=types.SpeechConfig(
         multi_speaker_voice_config=types.MultiSpeakerVoiceConfig(
            speaker_voice_configs=[
               types.SpeakerVoiceConfig(
                  speaker='Dr. Anya',
                  voice_config=types.VoiceConfig(
                     prebuilt_voice_config=types.PrebuiltVoiceConfig(
                        voice_name='Kore',
                     )
                  )
               ),
               types.SpeakerVoiceConfig(
                  speaker='Liam',
                  voice_config=types.VoiceConfig(
                     prebuilt_voice_config=types.PrebuiltVoiceConfig(
                        voice_name='Puck',
                     )
                  )
               ),
            ]
         )
      )
   )
)

# ...Code to stream or save the output

JavaScript

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

async function main() {

const transcript = await ai.models.generateContent({
   model: "gemini-2.0-flash",
   contents: "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.",
   })

const response = await ai.models.generateContent({
   model: "gemini-2.5-flash-preview-tts",
   contents: transcript,
   config: {
      responseModalities: ['AUDIO'],
      speechConfig: {
         multiSpeakerVoiceConfig: {
            speakerVoiceConfigs: [
                   {
                     speaker: "Dr. Anya",
                     voiceConfig: {
                        prebuiltVoiceConfig: {voiceName: "Kore"},
                     }
                  },
                  {
                     speaker: "Liam",
                     voiceConfig: {
                        prebuiltVoiceConfig: {voiceName: "Puck"},
                    }
                  }
                ]
              }
            }
      }
  });
}
// ..JavaScript code for exporting .wav file for output audio

await main();

音声オプション

TTS モデルは、voice_name フィールドで次の 30 個の音声オプションをサポートしています。

Zephyr -- Bright Puck - Upbeat Charon - 情報が豊富
Kore -- Firm Fenrir -- Excitable Leda -- Youthful
Orus -- Firm Aoede -- Breezy Callirrhoe - おおらか
Autonoe -- Bright Enceladus - Breathy Iapetus -- Clear
Umbriel -- Easy-going Algieba -- Smooth Despina -- Smooth
Erinome -- クリア Algenib -- Gravelly Rasalgethi - 情報が豊富
Laomedeia - アップビート Achernar -- Soft Alnilam -- Firm
Schedar -- Even Gacrux -- 成人向け Pulcherrima -- 転送
Achird -- フレンドリー Zubenelgenubi -- Casual Vindemiatrix - Gentle
Sadachbia -- Lively Sadaltager -- 知識が豊富 Sulafat -- Warm

AI Studio で、すべての音声オプションを聞くことができます。

サポートされている言語

TTS モデルは入力言語を自動的に検出します。次の 24 言語をサポートしています。

言語 BCP-47 コード 言語 BCP-47 コード
アラビア語(エジプト) ar-EG ドイツ語(ドイツ) de-DE
英語(米国) en-US スペイン語(米国) es-US
フランス語(フランス) fr-FR ヒンディー語(インド) hi-IN
インドネシア語(インドネシア) id-ID イタリア語(イタリア) it-IT
日本語(日本) ja-JP 韓国語(韓国) ko-KR
ポルトガル語(ブラジル) pt-BR ロシア語(ロシア) ru-RU
オランダ語(オランダ) nl-NL ポーランド語(ポーランド) pl-PL
タイ語(タイ) th-TH トルコ語(トルコ) tr-TR
ベトナム語(ベトナム) vi-VN ルーマニア語(ルーマニア) ro-RO
ウクライナ語(ウクライナ) uk-UA ベンガル語(バングラデシュ) bn-BD
英語(インド) en-INhi-IN のセット マラーティー語(インド) mr-IN
タミル語(インド) ta-IN テルグ語(インド) te-IN

サポートされているモデル

モデル 単一話者 マルチスピーカー
Gemini 2.5 Flash プレビュー TTS ✔️ ✔️
Gemini 2.5 Pro プレビュー TTS ✔️ ✔️

制限事項

  • TTS モデルはテキスト入力のみを受け取り、音声出力を生成します。
  • TTS セッションのコンテキスト ウィンドウの上限は 32,000 トークンです。
  • 言語のサポートについては、言語セクションをご覧ください。

プロンプト ガイド

Gemini ネイティブ音声生成テキスト読み上げ(TTS)モデルは、何を言うかだけでなく、どのように言うかも知っている大規模言語モデルを使用することで、従来の TTS モデルと差別化されています。

この機能を活用するには、ユーザーは仮想音声タレントが演じるシーンを設定する監督になったつもりで操作します。プロンプトを作成するには、次のコンポーネントを検討することをおすすめします。キャラクターの核となるアイデンティティとアーキタイプを定義する音声プロファイル、物理環境と感情的な「雰囲気」を確立するシーンの説明、スタイル、アクセント、ペースの制御に関するより正確なパフォーマンス ガイダンスを提供する監督のメモ

正確な地域アクセント、特定のパラ言語的特徴(息遣いなど)、ペースなど、ニュアンスのある指示を提供することで、ユーザーはモデルのコンテキスト認識を活用して、非常にダイナミックで自然で表現力豊かな音声パフォーマンスを生成できます。最適なパフォーマンスを得るには、トランスクリプトと演出指示が一致するようにすることをおすすめします。「誰が言っているか」「何を言っているか」「どのように言っているか」に一致するようにします。

このガイドの目的は、Gemini TTS 音声生成を使用して音声エクスペリエンスを開発する際に、基本的な方向性を示し、アイデアを生み出すことです。皆様がどのようなものを作成されるか楽しみにしております。

プロンプトの構造

堅牢なプロンプトには、優れたパフォーマンスを実現するために次の要素が含まれていることが理想的です。

  • 音声プロファイル - 音声のペルソナを確立し、キャラクターのアイデンティティ、アーキタイプ、年齢や背景などのその他の特性を定義します。
  • Scene - 状況を設定します。物理的な環境と「雰囲気」の両方を説明します。
  • ディレクターのメモ - バーチャル タレントが注意すべき重要な指示を分類できるパフォーマンス ガイダンス。スタイル、呼吸、ペース、発音、アクセントなどが例として挙げられます。
  • コンテキストのサンプル - モデルにコンテキストの開始点を与え、設定したシーンに仮想アクターが自然に登場できるようにします。
  • Transcript - モデルが読み上げるテキスト。最適なパフォーマンスを得るには、文字起こしのトピックと文体が、指示内容と関連している必要があります。

プロンプトの例:

# AUDIO PROFILE: Jaz R.
## "The Morning Hype"

## THE SCENE: The London Studio
It is 10:00 PM in a glass-walled studio overlooking the moonlit London skyline,
but inside, it is blindingly bright. The red "ON AIR" tally light is blazing.
Jaz is standing up, not sitting, bouncing on the balls of their heels to the
rhythm of a thumping backing track. Their hands fly across the faders on a
massive mixing desk. It is a chaotic, caffeine-fueled cockpit designed to wake
up an entire nation.

### DIRECTOR'S NOTES
Style:
* The "Vocal Smile": You must hear the grin in the audio. The soft palate is
always raised to keep the tone bright, sunny, and explicitly inviting.
* Dynamics: High projection without shouting. Punchy consonants and elongated
vowels on excitement words (e.g., "Beauuutiful morning").

Pace: Speaks at an energetic pace, keeping up with the fast music.  Speaks
with A "bouncing" cadence. High-speed delivery with fluid transitions — no dead
air, no gaps.

Accent: Jaz is from Brixton, London

### SAMPLE CONTEXT
Jaz is the industry standard for Top 40 radio, high-octane event promos, or any
script that requires a charismatic Estuary accent and 11/10 infectious energy.

#### TRANSCRIPT
Yes, massive vibes in the studio! You are locked in and it is absolutely
popping off in London right now. If you're stuck on the tube, or just sat
there pretending to work... stop it. Seriously, I see you. Turn this up!
We've got the project roadmap landing in three, two... let's go!

プロンプト戦略の詳細

プロンプトの各要素を分解してみましょう。

音声プロファイル

キャラクターのペルソナを簡単に説明します。

  • 名前。キャラクターに名前を付けると、モデルとパフォーマンスが密接に結びつきます。シーンとコンテキストを設定するときは、名前でキャラクターを参照してください。
  • ロール。シーンで演じられているキャラクターの核となるアイデンティティとアーキタイプ。例: ラジオ DJ、ポッドキャスト配信者、ニュースレポーターなど

例:

# AUDIO PROFILE: Jaz R.
## "The Morning Hype"


# AUDIO PROFILE: Monica A.
## "The Beauty Influencer"

シーン

シーンのコンテキストを設定します。場所、雰囲気、環境の詳細など、トーンとバイブスを確立する要素を含めます。キャラクターの周囲で何が起こっているか、それがキャラクターにどのような影響を与えているかを説明します。シーンは、インタラクション全体の環境コンテキストを提供し、演技のパフォーマンスを微妙かつ自然な方法でガイドします。

例:

## THE SCENE: The London Studio
It is 10:00 PM in a glass-walled studio overlooking the moonlit London skyline,
but inside, it is blindingly bright. The red "ON AIR" tally light is blazing.
Jaz is standing up, not sitting, bouncing on the balls of their heels to the
rhythm of a thumping backing track. Their hands fly across the faders on a
massive mixing desk. It is a chaotic, caffeine-fueled cockpit designed to
wake up an entire nation.


## THE SCENE: Homegrown Studio
A meticulously sound-treated bedroom in a suburban home. The space is
deadened by plush velvet curtains and a heavy rug, but there is a
distinct "proximity effect."

ディレクターのメモ

この重要なセクションには、パフォーマンスに関する具体的なガイダンスが含まれています。他の要素はすべてスキップできますが、この要素を含めることをおすすめします。

パフォーマンスにとって重要なものだけを定義し、過剰な指定をしないように注意してください。厳格なルールが多すぎると、モデルの創造性が制限され、パフォーマンスが低下する可能性があります。役柄とシーンの説明と、具体的な演技のルールとのバランスを取ります。

最も一般的な方向性は「スタイル、ペース、アクセント」ですが、モデルはこれらに限定されず、これらを必要としません。パフォーマンスに影響するその他の重要な詳細をカバーするために、カスタム手順を自由に追加できます。必要なだけ詳細に記述してください。

次に例を示します。

### DIRECTOR'S NOTES

Style: Enthusiastic and Sassy GenZ beauty YouTuber

Pacing: Speaks at an energetic pace, keeping up with the extremely fast, rapid
delivery influencers use in short form videos.

Accent: Southern california valley girl from Laguna Beach |

スタイル:

生成された音声のトーンとスタイルを設定します。パフォーマンスをガイドするために、アップビート、エネルギッシュ、リラックス、退屈などの要素を含めます。説明的で、必要なだけ詳細に記述します。「伝染性の熱意。「エネルギッシュで熱狂的」とだけ言うよりも、「リスナーが大規模でエキサイティングなコミュニティ イベントの一員であると感じられるようにする」という方が効果的です。

「ボーカル スマイル」など、ナレーション業界でよく使われる用語を試してみることもできます。スタイル特性は、必要なだけ重ねることができます。

例:

Simple Emotion

DIRECTORS NOTES
...
Style: Frustrated and angry developer who can't get the build to run.
...

奥行きを増やす

DIRECTORS NOTES
...
Style: Sassy GenZ beauty YouTuber, who mostly creates content for YouTube Shorts.
...

複雑

DIRECTORS NOTES
Style:
* The "Vocal Smile": You must hear the grin in the audio. The soft palate is
always raised to keep the tone bright, sunny, and explicitly inviting.
*Dynamics: High projection without shouting. Punchy consonants and
elongated vowels on excitement words (e.g., "Beauuutiful morning").

アクセント:

希望するアクセントを説明します。プロンプトが具体的であるほど、より良い結果が得られます。たとえば、「英国のクロイドンで聞かれる英国英語のアクセント」と「英国のアクセント」を使用します。

例:

### DIRECTORS NOTES
...
Accent: Southern california valley girl from Laguna Beach
...


### DIRECTORS NOTES
...
Accent: Jaz is a from Brixton, London
...

ペース:

全体的なペースと、作品全体を通してのペースのバリエーション。

例:

シンプル

### DIRECTORS NOTES
...
Pacing: Speak as fast as possible
...

詳細

### DIRECTORS NOTES
...
Pacing: Speaks at a faster, energetic pace, keeping up with fast paced music.
...

複雑

### DIRECTORS NOTES
...
Pacing: The "Drift": The tempo is incredibly slow and liquid. Words bleed into each other. There is zero urgency.
...

まずはお試しください

AI Studio でこれらの例を試したり、TTS アプリで遊んだり、Gemini に監督の椅子に座らせてもらったりしてみてください。素晴らしいボーカル パフォーマンスを実現するためのヒントを以下に示します。

  • プロンプト全体の一貫性を保つようにしてください。スクリプトと演出は、優れたパフォーマンスを生み出すために不可欠です。
  • すべてを説明する必要はありません。モデルがギャップを埋める余地を残すことで、自然な文章になります。(まるで才能のある俳優のように)
  • 行き詰まったときは、Gemini に手伝ってもらって、脚本やパフォーマンスを作成しましょう。

次のステップ

  • 音声生成クックブックを試す。
  • Gemini の Live API は、他のモダリティと組み合わせることができるインタラクティブな音声生成オプションを提供します。
  • 音声入力の操作については、音声認識ガイドをご覧ください。