Gemini-TTS 是最新推出的文字轉語音技術,不僅能生成自然聽感的語音,還可根據文字提示詞精細控制生成的音訊。有了 Gemini-TTS,無論是簡短文字片段還是長篇敘事,都能合成單人或多人語音,還可以透過自然語言提示詞精準指定風格、口音、語速、語氣,甚至是表達情緒。
可用模型
Gemini-TTS 包含下列可用模型:
Gemini 2.5 Flash TTS
| 模型 ID | gemini-2.5-flash-tts |
|---|---|
| 適合用途 | 生成單一和多位說話者的文字轉語音音訊,延遲時間短、可控制,適用於日常應用程式,經濟實惠 |
| 輸入和輸出模態 |
|
| 支援的說話者人數 | 單一、多位說話者 |
| 支援的輸出音訊格式* | LINEAR16 (預設)、ALAW、MULAW、MP3、OGG_OPUS、PCM |
| 支援的區域 | 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 |
|---|---|
| 適合用途 | 高度控管結構化工作流程,例如生成 Podcast、有聲書、客戶服務等 |
| 輸入和輸出模態 |
|
| 支援的說話者人數 | 單一、多位說話者 |
| 支援的輸出音訊格式* | LINEAR16 (預設)、ALAW、MULAW、MP3、OGG_OPUS、PCM |
| 支援的區域 | 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"
|
* 僅限 batch。不支援 streaming。
其他控制項
其他控制項和功能包括:
自然對話:語音互動品質極佳,表達方式和節奏模式更加自然,且延遲時間極短,對話流暢無礙。
風格控制:使用自然語言提示詞,即可在對話中調整語氣,讓對話採用特定口音,並產生各種語調和表達方式,包括輕聲耳語。
動態朗讀:這些模型能生動朗讀文字,例如詩歌、新聞報導和引人入勝的故事,還能依要求以特定情緒表演,或是模仿口音。
加強控制語速和發音:控制語速有助於確保發音更準確,包括讀出特定字詞。
如要瞭解如何在應用程式中使用這些語音,請參閱「使用 Gemini-TTS」。
語音選項
Gemini-TTS 提供多種語音選項,與現有的「Chirp 3:HD 語音」類似,但各有不同特色:
| 名稱 | 性別 | 示範 |
|---|---|---|
| Achernar | 女性 | |
| Achird | 男性 | |
| Algenib | 男性 | |
| Algieba | 男性 | |
| Alnilam | 男性 | |
| Aoede | 女性 | |
| Autonoe | 女性 | |
| Callirrhoe | 女性 | |
| Charon | 男性 | |
| Despina | 女性 | |
| Enceladus | 男性 | |
| Erinome | 女性 | |
| Fenrir | 男性 | |
| Gacrux | 女性 | |
| Iapetus | 男性 | |
| Kore | 女性 | |
| Laomedeia | 女性 | |
| Leda | 女性 | |
| Orus | 男性 | |
| Pulcherrima | 女性 | |
| Puck | 男性 | |
| Rasalgethi | 男性 | |
| Sadachbia | 男性 | |
| Sadaltager | 男性 | |
| Schedar | 男性 | |
| Sulafat | 女性 | |
| Umbriel | 男性 | |
| Vindemiatrix | 女性 | |
| Zephyr | 女性 | |
| Zubenelgenubi | 男性 |
支援的語言
Gemini-TTS 支援下列語言:
| 語言 | BCP-47 代碼 | 發布準備完成度 |
|---|---|---|
| 阿拉伯文 (埃及) | ar-EG | 正式發布版 |
| 荷蘭文 (荷蘭) | nl-NL | 正式發布版 |
| 英文 (印度) | en-IN | 正式發布版 |
| 英文 (美國) | en-US | 正式發布版 |
| 法文 (法國) | fr-FR | 正式發布版 |
| 德文 (德國) | de-DE | 正式發布版 |
| 北印度文 (印度) | hi-IN | 正式發布版 |
| 印尼文 (印尼) | id-ID | 正式發布版 |
| 義大利文 (義大利) | it-IT | 正式發布版 |
| 日文 (日本) | ja-JP | 正式發布版 |
| 韓文 (韓國) | ko-KR | 正式發布版 |
| 馬拉地文 (印度) | mr-IN | 正式發布版 |
| 波蘭文 (波蘭) | pl-PL | 正式發布版 |
| 葡萄牙文 (巴西) | pt-BR | 正式發布版 |
| 羅馬尼亞文 (羅馬尼亞) | ro-RO | 正式發布版 |
| 俄文 (俄羅斯) | ru-RU | 正式發布版 |
| 西班牙文 (西班牙) | es-ES | 正式發布版 |
| 泰米爾文 (印度) | ta-IN | 正式發布版 |
| 泰盧固文 (印度) | te-IN | 正式發布版 |
| 泰文 (泰國) | th-TH | 正式發布版 |
| 土耳其文 (土耳其) | tr-TR | 正式發布版 |
| 烏克蘭文 (烏克蘭) | uk-UA | 正式發布版 |
| 越南文 (越南) | vi-VN | 正式發布版 |
| 南非荷蘭文 (南非) | 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 模型合成單人和多人語音。
事前準備
您必須先在Google Cloud 控制台啟用 API,才能開始使用 Text-to-Speech,步驟如下:
- 在專案中啟用 Text-to-Speech
- 確認已啟用 Text-to-Speech 的計費功能。
- 設定開發環境的驗證機制。
設定 Google Cloud 專案
-
您可以選擇現有專案或建立新專案。如要進一步瞭解如何建立專案,請參閱Google Cloud 說明文件。
如果選擇建立新專案,系統會顯示訊息,提示您連結帳單帳戶;如果選擇使用現有專案,請務必啟用計費功能。
選取專案並連結到帳單帳戶後,即可啟用 Text-to-Speech API。請前往頁面頂端的「Search products and resources」(搜尋產品和資源) 列,輸入「speech」,然後從結果清單中選取「Cloud Text-to-Speech API」。
如要試用 Text-to-Speech,但不想將這項工具連結到專案,請選擇「Try this API」(試用這個 API) 選項。如要啟用 Text-to-Speech API,以便搭配專案使用,請按一下「Enable」(啟用)。
設定開發環境的驗證機制。如需操作說明,請參閱「設定 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
使用任意形式的文字輸入內容,執行多位說話者同步合成作業
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
使用結構化文字輸入內容,執行多位說話者同步合成作業
根據結構化文字輸入內容,以類似人類的口吻將文字轉換成多人語音。舉例來說,這類輸入內容適用於地址和日期。如果是任意形式的文字輸入內容,系統會完全按照撰寫內容朗讀。
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」頁面。
從媒體下拉式選單中選取「Speech」(語音)。
在文字欄位中,輸入要合成語音的文字。
在「Settings」(設定) 窗格中完成下列設定:
- 模型:選取要使用的文字轉語音 (TTS) 模型,例如
Gemini 2.5 Pro TTS。如要進一步瞭解可用模型,請參閱「文字轉語音模型」。 - 風格指令:(選用) 輸入文字提示詞,描述想要的說話風格、語氣和情緒,藉此引導模型,讓最終的語音表現超越預設水準。例如:「Narrate in a calm, professional tone for a documentary.」(以平靜專業的語氣為紀錄片配旁白。)
- 語言:選取輸入文字的語言和地區。模型會以所選語言和口音生成語音,例如「English (United States)」(英文 (美國))。
- 語音:選擇預先定義的旁白語音。清單會顯示所選模型和語言的可用語音,例如「Acherner (Female)」(Acherner (女性))。
- 模型:選取要使用的文字轉語音 (TTS) 模型,例如
(選用) 展開「Advanced options」(進階選項) 部分,設定音訊技術設定:
- 音訊編碼:選取輸出音訊檔案的編碼方式。
LINEAR16是無失真且未經壓縮的格式,適合用於處理高品質音訊。MULAW也適用於輸出壓縮音訊。 - 音訊取樣率:選擇取樣率,單位為赫茲 (Hz)。這項設定會決定音質。這個值越高 (例如 44,100 Hz),代表音訊保真度越高,相當於 CD 音質。
- 速度:移動滑桿或輸入值,即可調整語速。值低於 1.0 會減緩語速,值高於 1.0 則會加快語速,預設值為 1。
- 音量增益 (分貝):以分貝 (dB) 為單位調整輸出音訊的音量。正值會調高音量,負值則會調低音量。預設值為 0。
- 音訊編碼:選取輸出音訊檔案的編碼方式。
按一下文字方塊右側的「傳送」圖示,即可生成音訊。
生成的音訊會顯示在媒體播放器中,點按播放按鈕即可聆聽輸出內容。您可以繼續調整設定,並視需要生成新版本。
提示詞訣竅
如要根據文字內容建立自然流暢的語音,必須先瞭解口語表達與將口語轉換成腳本的細微差異。請參考下列訣竅,撰寫出真實且符合所選語氣的腳本。
語音控制的三個技巧
如要獲得可預測性最高且細緻的結果,請確保下列三個元件都與所需輸出內容一致。
風格提示詞:主要用來決定整體情緒基調和傳達方式,這個提示詞會為整段語音設定情境。
範例:
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]) 最適合用於插入特定本地化動作或風格修改項目,而非設定整體語氣。這些標記可與風格提示詞和文字內容相互配合。
標記指南
研究顯示,用方括號括住的標記會以三種不同模式運作。瞭解標記模式是有效使用標記的關鍵。
模式 1:非語音聲音
標記會替換為可聽見的非語音發聲 (例如嘆氣、笑聲)。系統不會唸出標記本身。這類語音很適合加入真實、類似人類的遲疑和反應。
| 標記 | 行為 | 可靠性 | 指引 |
|---|---|---|---|
[sigh] |
插入嘆氣聲。 | 高 | 嘆氣的情緒品質會受到提示詞影響。 |
[laughing] |
插入笑聲。 | 高 | 為達最佳效果,請使用具體提示詞。比方說,一般提示詞可能會產生驚訝的笑聲,而「react with an amused laugh」(用開心的笑聲回應) 則會產生愉悅的笑聲。 |
[uhm] |
插入猶豫聲。 | 高 | 有助於營造更自然流暢的對話感。 |
模式 2:風格修飾符
系統不會朗讀標記,但會調整後續語音的傳達方式。調整的範圍和時間長度可能有所不同。
| 標記 | 行為 | 可靠性 | 指引 |
|---|---|---|---|
[sarcasm] |
為後續詞組加上諷刺的語氣。 | 高 | 這個標記是強大的修飾符,表示抽象概念可以成功引導模型的傳達語氣。 |
[robotic] |
使後續語音聽起來像機器人。 | 高 | 效果可套用到整個詞組。我們仍建議使用支持性風格提示詞 (例如「Say this in a robotic way」(用機器人語氣說這段文字)),以利獲得最佳結果。 |
[shouting] |
調高後續語音的音量。 | 高 | 搭配相符的風格提示詞 (例如「Shout this next part」(大聲說出下一段內容)) 和暗示大聲說話的文字,效果最佳。 |
[whispering] |
降低後續語音的音量。 | 高 | 如果風格提示詞也很明確 (例如「now whisper this part as quietly as you can」(現在盡可能輕聲細語地說出這段文字)),可獲得最佳結果。 |
[extremely fast] |
提高後續語音的速度。 | 高 | 適合用於免責事項或快速對話,幾乎不用進行提示工程。 |
模式 3:發音標記 (形容詞)
標記本身會以單字形式朗讀,同時影響整個句子的語氣。這種行為通常適用於情緒形容詞。
警告:系統會朗讀標記本身,因此在大多數情況下,這個模式可能會產生不必要的連帶效應。建議改用風格提示詞來設定情緒基調。
| 標記 | 行為 | 可靠性 | 指引 |
|---|---|---|---|
[scared] |
說出「scared」(害怕) 一詞,句子會採用害怕的語氣。 | 高 | 語氣效果取決於文字內容。「I just heard a window break」(我剛才聽到窗戶破裂聲) 這句話會產生確切害怕的結果。中性詞組會產生「詭異」但較不真實的結果。 |
[curious] |
說出「curious」(好奇) 一詞,句子會採用好奇的語氣。 | 高 | 使用疑問句支援標記的意圖。 |
[bored] |
說出「bored」(無聊) 一詞,句子會採用無聊的平淡語氣。 | 高 | 建議搭配平淡或重複的文字使用,效果最佳。 |
模式 4:節奏和停頓
這些標記會在生成的音訊中插入停頓,讓您精細控制節奏、時間和速度。標準標點符號 (逗號、句號、分號) 也會產生自然停頓,但使用這些標記可更明確的控管效果。
| 標記 | 行為 | 可靠性 | 指引 |
|---|---|---|---|
[short pause] |
插入短暫停頓,類似於逗號 (~250 毫秒)。 | 高 | 用來分隔子句或清單項目,讓內容更清楚。 |
[medium pause] |
插入標準停頓,類似於句子中斷 (約 500 毫秒)。 | 高 | 有效分隔不同句子或想法。 |
[long pause] |
插入明顯的停頓,營造戲劇性效果 (約 1000 毫秒以上)。 | 高 | 用於營造戲劇性效果,例如:「The answer is...[long pause]...no.」(答案是…拒絕。)請避免過度使用,否則聽起來會不自然。 |
確保結果可靠的關鍵策略
善用所有三個技巧。為獲得可預測性最高的結果,請確認風格提示詞、文字內容和所有標記在語意方面都保持一致,而且鎖定相同目標。
使用情感豐富的文字。不要只依賴提示詞和標記。提供豐富的描述性文字,讓模型據此生成內容。如果想呈現諷刺、恐懼或興奮等細微情緒,這點尤其重要。
輸入具體詳細的提示詞。風格提示詞越具體,結果就越可靠。比方說,「React with an amused laugh」(用開心的笑聲回應) 比單純的
[laughing]更能傳達情緒。「Speak like a 1940s radio news announcer」(用 1940 年代的電台新聞播報員風格說話) 比「Speak in an old-fashioned way」(用老派風格說話) 更能獲得最佳效果。測試及驗證新標記。如果是新標記或未經測試的標記,行為有時會難以預測。您認為是風格修飾符的標記可能會發音。因此,請務必先測試新的標記或提示詞組合,確認行為後,再部署到正式環境。