Gemini-TTS は、Cloud TTS テクノロジーの最新の進化形であり、自然な音声を超えて、テキストベースのプロンプトを使用して生成音声を細かく制御できます。Gemini-TTS を使用すると、短い断片的な文章から長文のナラティブまで、単一話者または複数話者の音声を合成できます。スタイル、アクセント、速度、声のトーン、さらに感情表現まで正確に指定できます。しかも、すべて自然言語のプロンプトでコントロール可能です。
使用可能なモデル
Gemini-TTS には、次の利用可能なモデルが含まれています。
Gemini 2.5 Flash TTS
| モデル ID | gemini-2.5-flash-tts |
|---|---|
| 適した用途 | 低レイテンシで制御可能な、単一話者および複数話者の Cloud TTS 音声生成により、費用対効果の高い日常的なアプリケーションを実現 |
| 入力と出力のモダリティ |
|
| 話者数のサポート | 単一、複数話者 |
| サポートされている出力音声形式 |
|
| リージョン サポート | global |
| 音声オプション | 音声オプションをご覧ください。 |
| 対応言語 | 利用できる言語をご覧ください。 |
| 例 |
model: "gemini-2.5-flash-tts"
prompt: "Say the following"
text: "[extremely fast] Availability and terms may vary.
Check our website or your local store for complete
details and restrictions."
speaker: "Kore"
|
Gemini 2.5 Pro TTS
| モデル ID | gemini-2.5-pro-tts |
|---|---|
| 適した用途 | ポッドキャスト制作、オーディオブック、カスタマー サポートなどの構造化されたワークフローを高度に制御 |
| 入力と出力のモダリティ |
|
| 話者数のサポート | 単一、複数話者 |
| サポートされている出力音声形式 |
|
| リージョン サポート | global |
| 音声オプション | 音声オプションをご覧ください。 |
| 対応言語 | 利用できる言語をご覧ください。 |
| 例 |
model: "gemini-2.5-pro-tts"
prompt: "You are having a casual conversation with a friend.
Say the following in a friendly and amused way."
text: "hahah I did NOT expect that. Can you believe it!."
speaker: "Callirrhoe"
|
その他の制御
上記のほかに次のような制御オプションや機能があります。
自然な会話: 非常に低レイテンシで、優れた品質の音声インタラクション、より適切な表現とリズムのパターンが提供されるため、スムーズに会話できます。
スタイルの制御: 自然言語のプロンプトを使えば、会話の中で話し方を調整し、特定のアクセントを採用させたり、さまざまなトーンや表現(ささやき声など)を生成させたりすることができます。
動的なパフォーマンス: これらのモデルは、詩の表現豊かな朗読やニュース放送、引き込まれるようなストーリーテリングでテキストを生き生きと表現できます。また、リクエストに応じて特定の感情を込めて話したり、アクセントを付けたりすることも可能です。
ペースと発音のより詳細なコントロール: 話す速度を調整することで、特定の単語を含めて発音の精度を高めることができます。
アプリケーションでこれらの音声を使用する方法については、Gemini-TTS を使用するをご覧ください。
音声オプション
Gemini-TTS には、既存の Chirp 3: HD 音声と同様に、それぞれに特徴のあるさまざまな音声オプションが用意されています。
| 名前 | 性別 | デモ |
|---|---|---|
| アケルナル | 女性 | |
| アキアード | 男性 | |
| アルゲニブ | 男性 | |
| アルギエバ | 男性 | |
| アルニラム | 男性 | |
| アオエデ | 女性 | |
| オウトノエ | 女性 | |
| カリュローエ | 女性 | |
| カロン | 男性 | |
| デスピナ | 女性 | |
| エンケラドゥス | 男性 | |
| エリノメ | 女性 | |
| Fenrir | 男性 | |
| ガクラックス | 女性 | |
| イアペトゥス | 男性 | |
| Kore | 女性 | |
| ラオメデイア | 女性 | |
| Leda | 女性 | |
| Orus | 男性 | |
| プルケリマ | 女性 | |
| Puck | 男性 | |
| ラサルゲティ | 男性 | |
| サダクビア | 男性 | |
| サダルタゲル | 男性 | |
| スケダル | 男性 | |
| スラファト | 女性 | |
| アムブリエル | 男性 | |
| ビンデミアトリクス | 女性 | |
| Zephyr | 女性 | |
| ズベンエルゲヌビ | 男性 |
対応言語
Gemini-TTS は次の言語をサポートしています。
| 言語 | BCP-47 コード | 提供状況 |
|---|---|---|
| アラビア語(エジプト) | ar-EG | GA |
| オランダ語(オランダ) | nl-NL | GA |
| 英語(インド) | en-IN | GA |
| 英語(米国) | en-US | GA |
| フランス語(フランス) | fr-FR | GA |
| ドイツ語(ドイツ) | de-DE | GA |
| ヒンディー語(インド) | hi-IN | GA |
| インドネシア語(インドネシア) | id-ID | GA |
| イタリア語(イタリア) | it-IT | GA |
| 日本語(日本) | ja-JP | GA |
| 韓国語(韓国) | ko-KR | GA |
| マラーティー語(インド) | mr-IN | GA |
| ポーランド語(ポーランド) | pl-PL | GA |
| ポルトガル語(ブラジル) | pt-BR | GA |
| ルーマニア語(ルーマニア) | ro-RO | GA |
| ロシア語(ロシア) | ru-RU | GA |
| スペイン語(スペイン) | es-ES | GA |
| タミル語(インド) | ta-IN | GA |
| テルグ語(インド) | te-IN | GA |
| タイ語(タイ) | th-TH | GA |
| トルコ語(トルコ) | tr-TR | GA |
| ウクライナ語(ウクライナ) | uk-UA | GA |
| ベトナム語(ベトナム) | vi-VN | GA |
| アフリカーンス語(南アフリカ) | af-ZA | プレビュー |
| アルバニア語(アルバニア) | sq-AL | プレビュー |
| アムハラ語(エチオピア) | am-ET | プレビュー |
| アラビア語(世界) | ar-001 | プレビュー |
| アルメニア語(アルメニア) | hy-AM | プレビュー |
| アゼルバイジャン語(アゼルバイジャン) | az-AZ | プレビュー |
| ベンガル語(バングラデシュ) | bn-BD | プレビュー |
| バスク語(スペイン) | eu-ES | プレビュー |
| ベラルーシ語(ベラルーシ) | be-BY | プレビュー |
| ブルガリア語(ブルガリア) | bg-BG | プレビュー |
| ビルマ語(ミャンマー) | my-MM | プレビュー |
| カタルーニャ語(スペイン) | ca-ES | プレビュー |
| セブアノ語(フィリピン) | ceb-PH | プレビュー |
| 中国語、北京語(中国) | cmn-CN | プレビュー |
| 中国語、北京語(台湾) | cmn-tw | プレビュー |
| クロアチア語(クロアチア) | hr-HR | プレビュー |
| チェコ語(チェコ共和国) | cs-CZ | プレビュー |
| デンマーク語(デンマーク) | da-DK | プレビュー |
| 英語(オーストラリア) | en-AU | プレビュー |
| 英語(イギリス) | en-GB | プレビュー |
| エストニア語(エストニア) | et-EE | プレビュー |
| フィリピン語(フィリピン) | fil-PH | プレビュー |
| フィンランド語(フィンランド) | fi-FI | プレビュー |
| フランス語(カナダ) | fr-CA | プレビュー |
| ガリシア語(スペイン) | gl-ES | プレビュー |
| ジョージア語(ジョージア) | ka-GE | プレビュー |
| ギリシャ語(ギリシャ) | el-GR | プレビュー |
| グジャラト語(インド) | gu-IN | プレビュー |
| ハイチ クレオール語(ハイチ) | ht-HT | プレビュー |
| ヘブライ語(イスラエル) | he-IL | プレビュー |
| ハンガリー語(ハンガリー) | hu-HU | プレビュー |
| アイスランド語(アイスランド) | is-IS | プレビュー |
| ジャワ語(ジャワ) | jv-JV | プレビュー |
| カンナダ語(インド) | kn-IN | プレビュー |
| コンカニ語(インド) | kok-IN | プレビュー |
| ラオ語(ラオス) | lo-LA | プレビュー |
| ラテン語(バチカン市国) | la-VA | プレビュー |
| ラトビア語(ラトビア) | lv-LV | プレビュー |
| リトアニア語(リトアニア) | lt-LT | プレビュー |
| ルクセングルグ語(ルクセンブルク) | lb-LU | プレビュー |
| マケドニア語(北マケドニア) | mk-MK | プレビュー |
| マイティリー語(インド) | mai-IN | プレビュー |
| マラガシ語(マダガスカル) | mg-MG | プレビュー |
| マレー語(マレーシア) | ms-MY | プレビュー |
| マラヤーラム語(インド) | ml-IN | プレビュー |
| モンゴル語(モンゴル) | mn-MN | プレビュー |
| ネパール語(ネパール) | ne-NP | プレビュー |
| ノルウェー語、ブークモール(ノルウェー) | nb-NO | プレビュー |
| ノルウェー語、ニーノシク(ノルウェー) | nn-NO | プレビュー |
| オディア語(インド) | or-IN | プレビュー |
| パシュトー語(アフガニスタン) | ps-AF | プレビュー |
| ペルシャ語(イラン) | fa-IR | プレビュー |
| ポルトガル語(ポルトガル) | pt-PT | プレビュー |
| パンジャブ語(インド) | pa-IN | プレビュー |
| セルビア語(セルビア) | sr-RS | プレビュー |
| シンド語(インド) | sd-IN | プレビュー |
| シンハラ語(スリランカ) | si-LK | プレビュー |
| スロバキア語(スロバキア) | sk-SK | プレビュー |
| スロベニア語(スロベニア) | sl-SI | プレビュー |
| スペイン語(ラテンアメリカ) | es-419 | プレビュー |
| スペイン語(メキシコ) | es-MX | プレビュー |
| スワヒリ語(ケニア) | sw-KE | プレビュー |
| スウェーデン語(スウェーデン) | sv-SE | プレビュー |
| ウルドゥー語(パキスタン) | ur-PK | プレビュー |
Gemini-TTS を使用する
Gemini-TTS モデルを使用して、単一話者と複数話者の音声を合成する方法について説明します。
| 説明 | 上限 | タイプ |
|---|---|---|
| テキスト フィールド | 4,000 バイト以下。 | 入力 |
| プロンプト フィールド | 4,000 バイト以下。 | 入力 |
| テキスト フィールドとプロンプト フィールド | 8,000 バイト以下。 | 入力 |
| 出力音声の長さ | 約 655 秒。入力テキストの結果として音声が 655 秒を超えた場合、音声は切り捨てられます。 | 出力 |
始める前に
Cloud Text-to-Speech の使用を開始する前に、次の手順でGoogle Cloud コンソールで API を有効にする必要があります。
- プロジェクトで Cloud Text-to-Speech を有効にする。
- Cloud Text-to-Speech の課金が有効になっていることを確認する。
- 開発環境の認証を設定する。
Google Cloud プロジェクトを設定する
-
既存のプロジェクトを選択するか、新しいプロジェクトを作成します。プロジェクトの作成の詳細については、Google Cloud のドキュメントをご覧ください。
新しいプロジェクトを作成すると、請求先アカウントをリンクするように求めるメッセージが表示されます。既存のプロジェクトを使用する場合は、課金を有効にしてください
プロジェクトを選択して請求先アカウントを関連付けると、Cloud Text-to-Speech API を有効にできます。ページの上部にある [プロダクトとリソースを検索] バーに「speech」と入力します。結果のリストから [Cloud Text-to-Speech API] を選択します。
プロジェクトに関連付けずに Cloud Text-to-Speech を試すには、[この API を試す] オプションを選択します。プロジェクトで Cloud Text-to-Speech API を有効にするには、[有効にする] をクリックします。
開発環境に対する認証を設定します。手順については、Cloud Text-to-Speech の認証を設定するをご覧ください。
同期単一話者合成を実行する
Python
# google-cloud-texttospeech minimum version 2.29.0 is required.
import os
from google.cloud import texttospeech
PROJECT_ID = os.getenv("GOOGLE_CLOUD_PROJECT")
def synthesize(prompt: str, text: str, output_filepath: str = "output.mp3"):
"""Synthesizes speech from the input text and saves it to an MP3 file.
Args:
prompt: Styling instructions on how to synthesize the content in
the text field.
text: The text to synthesize.
output_filepath: The path to save the generated audio file.
Defaults to "output.mp3".
"""
client = texttospeech.TextToSpeechClient()
synthesis_input = texttospeech.SynthesisInput(text=text, prompt=prompt)
# Select the voice you want to use.
voice = texttospeech.VoiceSelectionParams(
language_code="en-US",
name="Charon", # Example voice, adjust as needed
model_name="gemini-2.5-pro-tts"
)
audio_config = texttospeech.AudioConfig(
audio_encoding=texttospeech.AudioEncoding.MP3
)
# Perform the text-to-speech request on the text input with the selected
# voice parameters and audio file type.
response = client.synthesize_speech(
input=synthesis_input, voice=voice, audio_config=audio_config
)
# The response's audio_content is binary.
with open(output_filepath, "wb") as out:
out.write(response.audio_content)
print(f"Audio content written to file: {output_filepath}")
CURL
# Make sure to install gcloud cli, and sign in to your project.
# Make sure to use your PROJECT_ID value.
# The available models are gemini-2.5-flash-tts and gemini-2.5-pro-tts.
# To parse the JSON output and use it directly see the last line of the command.
# Requires JQ and ffplay library to be installed.
PROJECT_ID=YOUR_PROJECT_ID
curl -X POST \
-H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
-H "x-goog-user-project: $PROJECT_ID" \
-H "Content-Type: application/json" \
-d '{
"input": {
"prompt": "Say the following in a curious way",
"text": "OK, so... tell me about this [uhm] AI thing."
},
"voice": {
"languageCode": "en-us",
"name": "Kore",
"model_name": "gemini-2.5-flash-tts"
},
"audioConfig": {
"audioEncoding": "LINEAR16"
}
}' \
"https://texttospeech.googleapis.com/v1/text:synthesize" \
| jq -r '.audioContent' | base64 -d | ffplay - -autoexit
ストリーミングの単一話者合成を実行する
ストリーミング合成は、ユーザー エクスペリエンスで高速なレスポンスが重要なリアルタイム アプリケーションに適しています。ストリーミング接続では、API は音声が利用可能になると、小さなチャンクで音声を返します。
API の呼び出し元として、音声チャンクが到着したら、それらをクライアントに渡すようにしてください(ウェブアプリの場合は socketio を使用するなど)。
request_generator に示すように、入力チャンクを API に非同期で送信することはできますが、API は、クライアントが API にデータを送信しないことを示すシグナルとして Half-Close を送信したときにのみ、合成を開始します。
prompt フィールドは、連続するチャンクでは無視されるため、最初の入力チャンクで設定する必要があります。
Python
# google-cloud-texttospeech minimum version 2.29.0 is required.
import datetime
import os
import numpy as np
from google.cloud import texttospeech
PROJECT_ID = os.getenv("GOOGLE_CLOUD_PROJECT")
def synthesize(prompt: str, text_chunks: list[str], model: str, voice: str, locale: str):
"""Synthesizes speech from the input text.
Args:
prompt: Styling instructions on how to synthesize the content in
the text field.
text_chunks: Text chunks to synthesize. Note that The synthesis will
start when the client initiates half-close.
model: gemini tts model name. gemini-2.5-flash-tts, gemini-2.5-pro-tts
voice: voice name. example: leda, kore. Refer to available voices
locale: locale name, example: en-us. Refer to available locales.
"""
client = texttospeech.TextToSpeechClient()
config_request = texttospeech.StreamingSynthesizeRequest(
streaming_config=texttospeech.StreamingSynthesizeConfig(
voice=texttospeech.VoiceSelectionParams(
name=voice,
language_code=locale,
model_name=model
)
)
)
# Example request generator. A function like this can be linked to an LLM
# text generator and the text can be passed to the TTS API asynchronously.
def request_generator():
yield config_request
for i, text in enumerate(text_chunks):
yield texttospeech.StreamingSynthesizeRequest(
input=texttospeech.StreamingSynthesisInput(
text=text,
# Prompt is only supported in the first input chunk.
prompt=prompt if i == 0 else None,
)
)
request_start_time = datetime.datetime.now()
streaming_responses = client.streaming_synthesize(request_generator())
is_first_chunk_received = False
final_audio_data = np.array([])
num_chunks_received = 0
for response in streaming_responses:
# just a simple progress indicator
num_chunks_received += 1
print(".", end="")
if num_chunks_received % 40 == 0:
print("")
# measuring time to first audio
if not is_first_chunk_received:
is_first_chunk_received = True
first_chunk_received_time = datetime.datetime.now()
# accumulating audio. In a web-server scenario, you would want to
# "emit" audio to the frontend as soon as it arrives.
#
# For example using flask socketio, you could do the following
# from flask_socketio import SocketIO, emit
# emit("audio", response.audio_content)
# socketio.sleep(0)
audio_data = np.frombuffer(response.audio_content, dtype=np.int16)
final_audio_data = np.concatenate((final_audio_data, audio_data))
time_to_first_audio = first_chunk_received_time - request_start_time
time_to_completion = datetime.datetime.now() - request_start_time
audio_duration = len(final_audio_data) / 24_000 # default sampling rate.
print("\n")
print(f"Time to first audio: {time_to_first_audio.total_seconds()} seconds")
print(f"Time to completion: {time_to_completion.total_seconds()} seconds")
print(f"Audio duration: {audio_duration} seconds")
return final_audio_data
フリーフォーム テキスト入力で同期複数話者合成を実行する
| 説明 | 制約と上限 | タイプ |
|---|---|---|
| テキスト フィールド | 4,000 バイト以下 | 入力 |
| プロンプト フィールド | 4,000 バイト以下 | 入力 |
| テキスト フィールドとプロンプト フィールド | 8,000 バイト以下 | 入力 |
| スピーカーのエイリアス | 英数字(空白文字なし) | 入力 |
| 出力音声の長さ | 約 655 秒。入力テキストの結果として音声が 655 秒を超えた場合、音声は切り捨てられます。 | 出力 |
Python
# google-cloud-texttospeech minimum version 2.31.0 is required.
import os
from google.cloud import texttospeech
PROJECT_ID = os.getenv("GOOGLE_CLOUD_PROJECT")
def synthesize_multispeaker_freeform(
prompt: str,
text: str,
output_filepath: str = "output_non_turn_based.wav",
):
"""Synthesizes speech from non-turn-based input and saves it to a WAV file.
Args:
prompt: Styling instructions on how to synthesize the content in the
text field.
text: The text to synthesize, containing speaker aliases to indicate
different speakers. Example: "Sam: Hi Bob!\nBob: Hi Sam!"
output_filepath: The path to save the generated audio file. Defaults to
"output_non_turn_based.wav".
"""
client = texttospeech.TextToSpeechClient()
synthesis_input = texttospeech.SynthesisInput(text=text, prompt=prompt)
multi_speaker_voice_config = texttospeech.MultiSpeakerVoiceConfig(
speaker_voice_configs=[
texttospeech.MultispeakerPrebuiltVoice(
speaker_alias="Speaker1",
speaker_id="Kore",
),
texttospeech.MultispeakerPrebuiltVoice(
speaker_alias="Speaker2",
speaker_id="Charon",
),
]
)
voice = texttospeech.VoiceSelectionParams(
language_code="en-US",
model_name="gemini-2.5-pro-tts",
multi_speaker_voice_config=multi_speaker_voice_config,
)
audio_config = texttospeech.AudioConfig(
audio_encoding=texttospeech.AudioEncoding.LINEAR16,
sample_rate_hertz=24000,
)
response = client.synthesize_speech(
input=synthesis_input, voice=voice, audio_config=audio_config
)
with open(output_filepath, "wb") as out:
out.write(response.audio_content)
print(f"Audio content written to file: {output_filepath}")
CURL
# Make sure to install gcloud cli, and sign in to your project.
# Make sure to use your PROJECT_ID value.
# The available models are gemini-2.5-flash-tts and gemini-2.5-pro-tts
# To parse the JSON output and use it directly see the last line of the command.
# Requires JQ and ffplay library to be installed.
# google-cloud-texttospeech minimum version 2.31.0 is required.
PROJECT_ID=YOUR_PROJECT_ID
curl -X POST \
-H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
-H "x-goog-user-project: $PROJECT_ID" \
-H "Content-Type: application/json" \
-d '{
"input": {
"prompt": "Say the following as a conversation between friends.",
"text": "Sam: Hi Bob, how are you?\\nBob: I am doing well, and you?"
},
"voice": {
"languageCode": "en-us",
"modelName": "gemini-2.5-flash-tts",
"multiSpeakerVoiceConfig": {
"speakerVoiceConfigs": [
{
"speakerAlias": "Sam",
"speakerId": "Kore"
},
{
"speakerAlias": "Bob",
"speakerId": "Charon"
}
]
}
},
"audioConfig": {
"audioEncoding": "LINEAR16",
"sampleRateHertz": 24000
}
}' \
"https://texttospeech.googleapis.com/v1/text:synthesize" \
| jq -r '.audioContent' | base64 -d | ffplay - -autoexit
構造化テキスト入力を使用して同期複数話者合成を実行する
構造化されたテキスト入力による複数話者対応により、テキストを人間のような方法でインテリジェントに音声化できます。たとえば、この種の入力は住所や日付に便利です。自由形式のテキスト入力では、テキストが書かれたとおりに読み上げられます。
| 説明 | 制約と上限 | タイプ |
|---|---|---|
| MultiSpeakerMarkUp フィールド | 4,000 バイト以下 | 入力 |
| プロンプト フィールド | 4,000 バイト以下 | 入力 |
| MultiSpeakerMarkUp フィールドとプロンプト フィールド | 8,000 バイト以下 | 入力 |
| スピーカーのエイリアス | 英数字(空白文字なし) | 入力 |
| 出力音声の長さ | 約 655 秒。入力テキストの結果として音声が 655 秒を超えた場合、音声は切り捨てられます。 | 出力 |
Python
# google-cloud-texttospeech minimum version 2.31.0 is required.
import os
from google.cloud import texttospeech
PROJECT_ID = os.getenv("GOOGLE_CLOUD_PROJECT")
def synthesize_multispeaker_structured(
prompt: str,
turns: list[texttospeech.MultiSpeakerMarkup.Turn],
output_filepath: str = "output_turn_based.wav",
):
"""Synthesizes speech from turn-based input and saves it to a WAV file.
Args:
prompt: Styling instructions on how to synthesize the content in the
text field.
turns: A list of texttospeech.MultiSpeakerMarkup.Turn objects representing
the dialogue turns.
output_filepath: The path to save the generated audio file. Defaults to
"output_turn_based.wav".
"""
client = texttospeech.TextToSpeechClient()
synthesis_input = texttospeech.SynthesisInput(
multi_speaker_markup=texttospeech.MultiSpeakerMarkup(turns=turns),
prompt=prompt,
)
multi_speaker_voice_config = texttospeech.MultiSpeakerVoiceConfig(
speaker_voice_configs=[
texttospeech.MultispeakerPrebuiltVoice(
speaker_alias="Speaker1",
speaker_id="Kore",
),
texttospeech.MultispeakerPrebuiltVoice(
speaker_alias="Speaker2",
speaker_id="Charon",
),
]
)
voice = texttospeech.VoiceSelectionParams(
language_code="en-US",
model_name="gemini-2.5-pro-tts",
multi_speaker_voice_config=multi_speaker_voice_config,
)
audio_config = texttospeech.AudioConfig(
audio_encoding=texttospeech.AudioEncoding.LINEAR16,
sample_rate_hertz=24000,
)
response = client.synthesize_speech(
input=synthesis_input, voice=voice, audio_config=audio_config
)
with open(output_filepath, "wb") as out:
out.write(response.audio_content)
print(f"Audio content written to file: {output_filepath}")
CURL
# Make sure to install gcloud cli, and sign in to your project.
# Make sure to use your PROJECT_ID value.
# The available models are gemini-2.5-flash-tts and gemini-2.5-pro-tts.
# To parse the JSON output and use it directly see the last line of the command.
# Requires JQ and ffplay library to be installed.
# google-cloud-texttospeech minimum version 2.31.0 is required.
PROJECT_ID=YOUR_PROJECT_ID
curl -X POST \
-H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
-H "x-goog-user-project: $PROJECT_ID" \
-H "Content-Type: application/json" \
-d '{
"input": {
"prompt": "Say the following as a conversation between friends.",
"multiSpeakerMarkup": {
"turns": [
{
"speaker": "Sam",
"text": "Hi Bob, how are you?"
},
{
"speaker": "Bob",
"text": "I am doing well, and you?"
}
]
}
},
"voice": {
"languageCode": "en-us",
"modelName": "gemini-2.5-flash-tts",
"multiSpeakerVoiceConfig": {
"speakerVoiceConfigs": [
{
"speakerAlias": "Sam",
"speakerId": "Kore"
},
{
"speakerAlias": "Bob",
"speakerId": "Charon"
}
]
}
},
"audioConfig": {
"audioEncoding": "LINEAR16",
"sampleRateHertz": 24000
}
}' \
"https://texttospeech.googleapis.com/v1/text:synthesize" \
| jq -r '.audioContent' | base64 -d | ffplay - -autoexit
Media Studio で音声合成を実行する
Google Google Cloud コンソールの Media Studio を使用して、テキスト読み上げモデルを試すことができます。これにより、合成音声の生成と試聴をすばやく行い、さまざまなスタイル指示やパラメータを試すためのユーザー インターフェースが提供されます。
Google Google Cloud コンソールで、[Vertex AI Studio] > [Media Studio] ページに移動します。
メディアのプルダウンから [音声] を選択します。
テキスト フィールドに、音声に変換するテキストを入力します。
[設定] ペインで、次の設定を構成します。
- モデル: 使用する Cloud TTS(TTS)モデル(
Gemini 2.5 Pro TTSなど)を選択します。使用可能なモデルの詳細については、Cloud TTS モデルをご覧ください。 - スタイルの指示: 省略可: 選択した話し方、トーン、感情の表現を説明するテキスト プロンプトを入力します。これにより、デフォルトのナレーションを超えてモデルのパフォーマンスをガイドできます。例: 「ドキュメンタリーのナレーションを落ち着いたプロフェッショナルなトーンでお願いします。」
- 言語: 入力テキストの言語と地域を選択します。モデルは、選択した言語とアクセントで音声を生成します。例: 英語(米国)
- 音声: ナレーションに使用する事前定義済みの音声を選択します。リストには、選択したモデルと言語で利用可能な音声が表示されます。例: アケルナル(女性)
- モデル: 使用する Cloud TTS(TTS)モデル(
省略可: [詳細オプション] セクションを開いて、技術的な音声設定を構成します。
- 音声エンコード: 出力音声ファイルのエンコードを選択します。
LINEAR16は、高音質オーディオ処理に適したロスレスの非圧縮形式です。MULAWは、圧縮された音声出力にも使用できます。 - 音声サンプルレート: サンプルレートをヘルツ(Hz)単位で選択します。これにより、音質が決まります。44,100 Hz などの高い値は、CD 品質に相当する高忠実度のオーディオを表します。
- 速度: スライダーを動かすか、値を入力して、発話速度を調整します。1 より小さい値を設定すると音声の速度が遅くなり、1 より大きい値を設定すると音声の速度が速くなります。デフォルトは 1 です。
- 音量ゲイン(dB): 出力音声の音量をデシベル(dB)単位で調整します。正の値は音量を上げ、負の値は音量を下げます。デフォルトは 0 です。
- 音声エンコード: 出力音声ファイルのエンコードを選択します。
テキスト ボックスの右側にある [送信] アイコンをクリックして、音声を生成します。
生成された音声がメディア プレーヤーに表示されます。再生ボタンをクリックして出力を聴きます。設定は引き続き調整でき、必要に応じて新しいバージョンを生成できます。
プロンプトに関するヒント
テキストから魅力的で自然な音声を作成するには、話し言葉のニュアンスを理解し、それをスクリプト形式に変換する必要があります。次のヒントを参考にして、信頼できるトーンを取り入れ、選んだトーンを表現するスクリプトを作成してください。
音声制御の 3 つのレバー
最も予測可能でニュアンスのある結果を得るには、次の 3 つのコンポーネントがすべて、目的の出力と一致していることを確認してください。
スタイル プロンプト全体的な感情のトーンと表現の主な原動力。プロンプトは、音声セグメント全体のコンテキストを設定します。
例:
You are an AI assistant speaking in a friendly and helpful tone.例:
Narrate this in the calm, authoritative tone of a nature documentary narrator.
テキスト コンテンツ合成する単語の意味論的意味。スタイル プロンプトと感情的に一致する印象的なフレーズを使用すると、中立的なテキストよりもはるかに信頼性の高い結果が得られます。
良い例: 怖がっている口調のプロンプトは、
I think someone is in the house.のようなテキストに最適です。効果的ではない例:
The meeting is at 4 PM.のようなテキストで怖がっている口調を求めるプロンプトは、曖昧な結果を生成します。
マークアップ タグ [sigh] のような角かっこで囲まれたタグは、全体的なトーンを設定するのではなく、特定のローカライズされたアクションやスタイルの変更を挿入する場合に最適です。スタイル プロンプトとテキスト コンテンツと連携して動作します。
マークアップ タグガイド
Google の調査によると、角かっこで囲まれたマークアップ タグは 3 つの異なるモードのいずれかで動作します。タグを効果的に使用するには、タグのモードを理解することが重要です。
モード 1: 会話以外の音声
マークアップは、音声以外の発話(ため息、笑いなど)に置き換えられます。タグ自体は読み上げられません。これらは、人間のようなリアルなためらいや反応を追加するのに最適です。
| タグ | 動作 | 信頼性 | ガイダンス |
|---|---|---|---|
[sigh] |
ため息の音を挿入します。 | 高 | ため息の感情的な質はプロンプトの影響を受けます。 |
[laughing] |
笑いを挿入します。 | 高 | 最適な結果を得るには、具体的なプロンプトを使用します。たとえば、一般的なプロンプトでは驚きの笑いになる可能性がありますが、「楽しそうな笑いで反応して」と指定すると、楽しそうな笑いになります。 |
[uhm] |
ためらう声を挿入します。 | 高 | より自然な会話の感覚を生み出すのに役立ちます。 |
モード 2: スタイル修飾子
マークアップは読み上げられませんが、後続の音声の配信を変更します。変更の範囲と期間は異なる場合があります。
| タグ | 動作 | 信頼性 | ガイダンス |
|---|---|---|---|
[sarcasm] |
次のフレーズに皮肉なトーンを加えます。 | 高 | このタグは強力な修飾子です。これは、抽象的なコンセプトがモデルの配信をうまく誘導できることを示しています。 |
[robotic] |
後続の音声がロボットのような音声になります。 | 高 | 効果はフレーズ全体に及ぶことがあります。サポート スタイルのプロンプト(例: 「ロボットのように話して」)を使用することをおすすめします。 |
[shouting] |
その後の音声の音量を上げます。 | 高 | 最も効果的なのは、対応するスタイルプロンプト(例: 「次の部分を叫んで」)と、叫び声を意味するテキストを組み合わせた場合です。 |
[whispering] |
その後の音声の音量を下げます。 | 高 | スタイル プロンプト(例: 「この部分はできるだけ静かにささやいてください」)も明示的な場合に最良の結果が得られます。 |
[extremely fast] |
後続の音声の速度を上げます。 | 高 | 免責事項やテンポの速い会話に最適です。プロンプトのサポートは最小限で済みます。 |
モード 3: 音声化されたマークアップ(形容詞)
マークアップ タグ自体は単語として発音されますが、文全体のトーンにも影響します。この動作は通常、感情を表す形容詞に適用されます。
警告: タグ自体が読み上げられるため、ほとんどのユースケースでは、このモードは望ましくない副作用となる可能性があります。代わりに、スタイル プロンプトを使用してこれらの感情的なトーンを設定することをおすすめします。
| タグ | 動作 | 信頼性 | ガイダンス |
|---|---|---|---|
[scared] |
「怖い」という言葉が発話されると、文が怖がっているトーンで表現される。 | 高 | パフォーマンスはテキスト コンテンツに大きく依存します。「窓が割れる音がした」というフレーズを入力すると、本当に怖がっている表現になります。中立的なフレーズを使用すると、不気味ではあるものの、本物らしさに欠ける結果が生成されます。 |
[curious] |
「珍しい」という単語が話されると、文が好奇心旺盛なトーンになる。 | 高 | タグの意図をサポートする探求的なフレーズを使用します。 |
[bored] |
「退屈」という単語が話されると、文が退屈で単調な話し方になる。 | 高 | 効果を最大限に引き出すには、平凡なテキストや繰り返しの多いテキストで使用します。 |
モード 4: ペーシングと一時停止
これらのタグは、生成された音声に無音を挿入し、リズム、タイミング、ペースを細かく制御できるようにします。標準の句読点(カンマ、ピリオド、セミコロン)でも自然な一時停止が作成されますが、これらのタグを使用すると、より明示的に制御できます。
| タグ | 動作 | 信頼性 | ガイダンス |
|---|---|---|---|
[short pause] |
コンマ(約 250 ミリ秒)と同様に、短い一時停止を挿入します。 | 高 | 節やリスト項目を区切って、わかりやすくするために使用します。 |
[medium pause] |
文の区切り(約 500 ミリ秒)と同様の標準的な一時停止を挿入します。 | 高 | 文や考えを区切るのに効果的です。 |
[long pause] |
ドラマチックな効果を生み出すために、大きな休止を挿入します(1,000 ミリ秒以上)。 | 高 | 劇的なタイミングで使用します。例: 「答えは... [long pause] ...いいえ。」不自然に聞こえる可能性があるため、過度の使用は避けてください。 |
信頼性の高い結果を得るための主な戦略
3 つのレバーをすべて調整する: 予測可能性を最大限に高めるには、スタイル プロンプト、テキスト コンテンツ、マークアップ タグがすべて意味的に一貫しており、同じ目標に向かって機能していることを確認します。
感情豊かなテキストを使用する: プロンプトとタグだけに頼らないでください。処理対象として、モデルに内容の充実した説明的なテキストを指定します。これは、皮肉、恐怖、興奮などの微妙な感情を理解するうえで特に重要です。
具体的で詳細なプロンプトを作成する: スタイル プロンプトが具体的であるほど、信頼性の高い結果が得られます。「楽しげな笑い声で反応する」は、単に
[laughing]と書くよりも優れています。「1940 年代のラジオ ニュース アナウンサーのように話して」は、「古風な話し方をして」よりも優れています。新しいタグをテストして検証する: 新しいタグやテストされていないタグの動作は、必ずしも予測できるとは限りません。スタイル修飾子だと思っていたタグが音声化されることがあります。新しいタグとプロンプトの組み合わせは、本番環境にデプロイする前に、必ずテストして動作を確認してください。
安全フィルタの緩和
月単位の請求書発行アカウントでは、AdvancedVoiceOptions の relax_safety_filters フィールドを使用して、安全フィルタを緩和するリクエストを構成できます。relax_safety_filters フィールドは、毎月の請求書発行によるお支払いをご利用のアカウントでのみ有効になります。
安全フィルタを緩和すると、有害なコンテンツの合成をブロックするしきい値が下がります。
Python
# google-cloud-texttospeech minimum version 2.32.0 is required.
request = texttospeech.SynthesizeSpeechRequest(
input=synthesis_input,
voice=voice,
audio_config=audio_config,
advanced_voice_options=texttospeech.AdvancedVoiceOptions(
relax_safety_filters=True,
),
)
# Perform the text-to-speech request on the text input with the selected
# voice parameters and audio file type.
response = client.synthesize_speech(request=request)
CURL
PROJECT_ID=YOUR_PROJECT_ID
curl -X POST \
-H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
-H "x-goog-user-project: $PROJECT_ID" \
-H "Content-Type: application/json" \
-d '{
"input": {
"prompt": "Say the following in a curious way",
"text": "I am saying something that would otherwise be blocked by Gemini TTS."
},
"voice": {
"languageCode": "en-us",
"name": "Kore",
"modelName": "gemini-2.5-flash-tts"
},
"audioConfig": {
"audioEncoding": "LINEAR16"
},
"advancedVoiceOptions": {
"relaxSafetyFilters": true
}
}' \
"https://texttospeech.googleapis.com/v1/text:synthesize" \
| jq -r '.audioContent' | base64 -d | ffplay - -autoexit