Gemini-TTS

試用 Colab 筆記本 在 GitHub 中查看筆記本

Gemini-TTS 是我們最新的文字轉語音技術,不僅能生成自然語音,還可透過文字提示精細控制生成的音訊。使用 Gemini-TTS,無論是簡短片段或完整故事,都能合成單人或多人語音,透過自然語言提示詞精準指定風格、口音、語速、語氣,甚至是情緒表達方式。

如要在控制台中探索這個模型,請前往 Model Garden (可透過「Media Studio」分頁存取),查看 Gemini-TTS 模型資訊卡。

在 Vertex AI (Vertex AI Studio) 上試用 Gemini-TTS

下列項目支援 Gemini-TTS 功能:

  • gemini-2.5-flash-tts:Gemini 2.5 Flash TTS 適合用於日常 TTS 應用程式,可有效節省成本。

  • gemini-2.5-pro-tts:Gemini 2.5 Pro TTS 適合用於可控的語音生成 (TTS),以及複雜提示的頂尖品質。

模型 適合用途 輸入模態 輸出模態 單一說話者 多名說話者
Gemini 2.5 Flash TTS 延遲時間短、可控制、單一和多位說話者文字轉語音音訊生成,適用於日常應用程式,經濟實惠 文字 音訊 ✔️ ✔️
Gemini 2.5 Pro TTS 高度控管結構化工作流程,例如生成 Podcast、有聲書、客戶服務等 文字 音訊 ✔️ ✔️

其他控制項和功能包括:

  1. 自然對話:語音互動品質極佳,表達方式和韻律 (節奏模式) 更貼近自然,且延遲時間極短,讓對話流暢無礙。

  2. 風格控制:使用自然語言提示,即可在對話中調整語氣,引導語音採用特定口音,並產生各種語調和表情,包括耳語。

  3. 動態朗讀:這些模型能生動朗讀文字,例如詩歌、新聞報導和引人入勝的故事。還能依要求以特定情緒表演,或模仿口音。

  4. 加強控制語速和發音:控制語速有助於確保發音更準確,包括特定字詞。

範例

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: "Callirhoe"

model: "gemini-2.5-flash-tts"
prompt: "Say the following in a curious way"
text: "OK, so... tell me about this [uhm] AI thing.",
speaker: "Orus"

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-TTS」一節。

語音選項

Gemini-TTS 提供多種語音選項,與現有的 Chirp 3:HD 語音類似,但各有不同特徵:

名稱 性別 示範
Achernar 女性
Achird 男性
Algenib 男性
Algieba 男性
Alnilam 男性
Aoede 女性
Autonoe 女性
Callirrhoe 女性
冥衛一 男性
Despina 女性
安塞拉杜斯 男性
Erinome 女性
Fenrir 男性
Gacrux 女性
埃爾皮塔斯 男性
Kore 女性
Laomedeia 女性
Leda 女性
Orus 男性
Pulcherrima 女性
球餅 男性
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 預覽
爪哇文 (Java) jv-JV 預覽
卡納達文 (印度) kn-IN 預覽
貢根文 (印度) kok-in 預覽
寮文 (寮國) lo-LA 預覽
拉丁文 (梵蒂岡) la-VA 預覽
拉脫維亞文 (拉脫維亞) lv-LV 預覽
立陶宛文 (立陶宛) lt-IT 預覽
盧森堡文 (盧森堡) lb-LU 預覽
馬其頓文 (北馬其頓) mk-MK 預覽
邁蒂利文 (印度) mai-IN 預覽
馬達加斯加文 (馬達加斯加) mg-MG 預覽
馬來文 (馬來西亞) ms-MY 預覽
馬拉雅拉姆文 (印度) ml-IN 預覽
蒙古文 (蒙古) mn-MN 預覽
尼泊爾文 (尼泊爾) ne-NP 預覽
挪威文 (巴克摩) (挪威) nb-NO 預覽
挪威文 (Nynorsk) (挪威) 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 模型分別在下列 Google Cloud 區域提供:

Google Cloud 區域 發布準備完成度
global 正式發布版

支援的輸出格式

預設回應格式為 LINEAR16。其他支援的格式包括:

API 方法 格式
batch ALAW、MULAW、MP3、OGG_OPUS 和 PCM
streaming 不支援

使用 Gemini-TTS

瞭解如何使用 Gemini-TTS 模型合成單一說話者和多位說話者的語音。

事前準備

您必須先在Google Cloud 控制台中啟用 API,才能使用 Text-to-Speech,步驟如下:

  1. 在專案中啟用 Text-to-Speech。
  2. 確認已啟用 Text-to-Speech 的計費功能。
  3. 為您的開發環境設定驗證方法。

設定您的 Google Cloud 專案

  1. 登入 Google Cloud 主控台

  2. 前往專案選取器頁面

    您可以選擇現有專案或建立新專案。如要進一步瞭解如何建立專案,請參閱Google Cloud 說明文件

  3. 如果您建立新專案,系統會顯示訊息,通知您連結帳單帳戶。如果您使用現有專案,請務必啟用計費功能

    瞭解如何確認專案已啟用計費功能

  4. 選取專案並連結至帳單帳戶後,即可啟用 Text-to-Speech API。前往頁面頂端的「搜尋產品和資源」列,然後輸入「speech」。從結果清單中選取「Cloud Text-to-Speech API」

  5. 如要試用 Text-to-Speech,但不想將其連結至專案,請選擇「試用這個 API」選項。如要啟用 Text-to-Speech API,以便在專案中使用,請按一下「啟用」

  6. 為開發環境設定驗證方法。如需操作說明,請參閱「設定 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 試用文字轉語音模型。這個使用者介面可快速生成及聆聽合成音訊,並測試不同的風格指令和參數。

  1. 在 Google Google Cloud 控制台中,前往「Vertex AI Studio」>「Media Studio」頁面。

    媒體工作室

  2. 從媒體下拉式選單中選取「語音」

  3. 在文字欄位中,輸入要合成語音的文字。

  4. 在「設定」窗格中,進行下列設定:

    1. 模型:選取要使用的文字轉語音 (TTS) 模型,例如 Gemini 2.5 Pro TTS。如要進一步瞭解可用模型,請參閱「文字轉語音模型」。
    2. 風格指示:選用:輸入文字提示,說明所選的說話風格、語氣和情緒。這樣一來,您就能引導模型,讓旁白表現超越預設水準。例如:「以平靜專業的語氣為紀錄片旁白。」
    3. 語言:選取輸入文字的語言和地區。模型會以所選語言和口音生成語音。例如「英文 (美國)」
    4. 語音:選擇旁白的預先定義語音。清單會顯示所選模型和語言的可用語音,例如「Acherner (女聲)」
  5. 選用:展開「進階選項」部分,設定音訊技術設定:

    1. 音訊編碼:選取輸出音訊檔案的編碼方式。LINEAR16 是無失真且未經壓縮的格式,適合用於處理高品質音訊。MULAW 也適用於壓縮音訊輸出。
    2. 音訊取樣率:選取取樣率 (單位為赫茲)。這會決定音訊品質。數值越高 (例如 44,100 Hz) 代表音訊保真度越高,相當於 CD 音質。
    3. 速度:移動滑桿或輸入值,即可調整說話速率。小於 1 的值會減緩語音速度,大於 1 的值則會加快語音速度。預設值是 1。
    4. 音量增益 (分貝):以分貝 (dB) 為單位調整輸出音訊的音量。正值會調高音量,負值則會調低音量。預設值為 0。
  6. 按一下文字方塊右側的「傳送」圖示,即可生成音訊。

  7. 生成的音訊會顯示在媒體播放器中。點選播放按鈕即可聆聽輸出內容。您可以繼續調整設定,並視需要生成新版本。

提示訣竅

如要從文字建立自然流暢的語音,必須先瞭解口語的細微差異,然後轉換成腳本。請參考下列提示,撰寫出真實且符合所選語氣的腳本。

語音控制的三個槓桿

如要獲得最可預測且細緻的結果,請確保下列三個元件都與所需輸出內容一致。

風格提示 整體情緒基調和傳達方式的主要驅動因素。提示會為整個語音片段設定情境。

  • 範例: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] 插入笑聲。 為達最佳效果,請使用具體提示。舉例來說,一般提示可能會產生驚訝的笑聲,而「以開心的笑聲回應」則會產生愉悅的笑聲。
[uhm] 插入猶豫聲。 有助於營造更自然流暢的對話感。

模式 2:樣式修飾符

系統不會朗讀標記,但會修改後續語音的傳達方式。修改範圍和時間長度可能有所不同。

標記 行為 可靠性 指引
[sarcasm] 為後續片語加上諷刺的語氣。 這個標記是強大的修飾符,這表示抽象概念可以成功引導模型放送廣告。
[robotic] 導致後續語音聽起來像機器人。 效果可套用至整個片語。支援的樣式提示 (例如「以機器人語氣說出這段文字」) 仍建議使用,可獲得最佳結果。
[shouting] 調高後續語音的音量。 搭配相符的樣式提示 (例如 「Shout this next part」(大聲說出下一段內容) 和暗示大聲說話的文字。
[whispering] 降低後續語音的音量。 如果風格提示也很明確 (例如「「現在請盡可能輕聲細語地說出這段文字」)。
[extremely fast] 加快後續語音的速度。 適合用於免責事項或快速對話。幾乎不必進行提示工程。

模式 3:發音標記 (形容詞)

標記標籤本身會以單字形式朗讀,同時影響整個句子的語氣。這類行為通常適用於情緒形容詞。

警告:由於系統會朗讀標記本身,因此在大多數情況下,這個模式可能會產生不必要的連帶影響。建議改用風格提示設定這些情緒基調。

標記 行為 可靠性 指引
[scared] 說出「害怕」一詞,句子會採用害怕的語氣。 成效取決於文字內容。「我剛聽到窗戶破裂的聲音」這句話會產生真正害怕的結果。中性詞組會產生「詭異」但較不真實的結果。
[curious] 說出「好奇」一詞,句子會採用好奇的語氣。 使用疑問句來支援標記的意圖。
[bored] 說出「無聊」一詞,句子會以無聊的單調語氣呈現。 建議搭配平淡或重複的文字使用,效果最佳。

模式 4:節奏和暫停

這些標記會在生成的音訊中插入靜音,讓您精細控制節奏、時間和速度。標準標點符號 (逗號、句號、分號) 也會產生自然停頓,但這些標記可提供更明確的控制。

標記 行為 可靠性 指引
[short pause] 插入短暫停頓,類似逗號 (~250 毫秒)。 用來分隔子句或清單項目,讓內容更清楚。
[medium pause] 插入標準停頓,類似於句子中斷 (約 500 毫秒)。 有效分隔不同句子或想法。
[long pause] 插入明顯的停頓,營造戲劇效果 (約 1000 毫秒以上)。 用於營造戲劇性效果。例如:「答案是... [long pause] ...no." 避免過度使用,否則聽起來會不自然。

確保結果可靠的關鍵策略

  • 調整所有三項槓桿 為確保預測結果準確無誤,請確認樣式提示、文字內容和所有標記標記在語意上一致,且都朝向相同目標。

  • 使用情感豐富的文字 不要只依賴提示和標記。提供豐富的描述性文字,讓模型可以運用。這對諷刺、恐懼或興奮等細微情緒尤其重要。

  • 撰寫具體詳細的提示詞 風格提示詞越具體,結果就越可靠。「React with an amused laugh」(以開心的笑聲回應) 比單純的 [laughing] 更能傳達情緒。「Speak like a 1940s radio news announcer」(用 1940 年代的電台新聞播報員風格說話) 比「Speak in an old-fashioned way」(用老派風格說話) 更具體。

  • 測試及驗證新代碼 新代碼或未經測試的代碼行為不一定可預測。您以為是樣式修飾符的標記可能會發音。請務必先測試新的代碼或提示組合,確認其行為,再部署到實際工作環境。