跳转到主要内容
POST
/
v3
/
gemini-2.5-flash-tts
Gemini 2.5 Flash TTS 文本转语音
curl --request POST \
  --url https://api.highwayapi.ai/v3/gemini-2.5-flash-tts \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: <content-type>' \
  --data '
{
  "contents": {
    "role": "<string>",
    "parts": {
      "text": "<string>"
    }
  },
  "generation_config": {
    "temperature": 123,
    "speech_config": {
      "voice_config": {
        "prebuilt_voice_config": {
          "voice_name": "<string>"
        }
      },
      "language_code": "<string>",
      "multi_speaker_voice_config": {
        "speaker_voice_configs": [
          {
            "speaker": "<string>",
            "voice_config": {
              "prebuilt_voice_config": {
                "voice_name": "<string>"
              }
            }
          }
        ]
      }
    }
  }
}
'
{
  "audioContent": "<string>",
  "usageMetadata": {
    "totalTokenCount": 123,
    "promptTokenCount": 123,
    "candidatesTokenCount": 123
  }
}
基于 Google Vertex AI generateContent 接口的 Gemini 2.5 Flash TTS。支持同步和流式单人/多人语音合成,通过自然语言提示词精确控制风格、口音、节奏、语调和情感表达。contents 字段最大 8000 字节,输出音频最长约 655 秒。Vertex AI 输出为 LINEAR16 PCM 格式(24kHz, 单声道),不包含 WAV 头。如需其他音频格式需客户端自行转换。

请求头

Content-Type
string
必填
枚举值: application/json
Authorization
string
必填
Bearer 身份验证格式: Bearer {{API 密钥}}。

请求体

contents
object
必填
generation_config
object
必填

响应信息

audioContent
string
Base64 编码的音频内容。格式为 LINEAR16 PCM(24kHz, 单声道, 16-bit signed little-endian),不包含 WAV 头。客户端可使用 ffmpeg 转换:ffmpeg -f s16le -ar 24k -ac 1 -i input.raw output.wav
usageMetadata
object