English
  • 中文
  • English
English
  • 中文
  • English
官网
服务状态
English
  • 中文
  • English
  1. Audio
  • Quickstart & Conventions
  • Images
    • GPT Image 2 / 2.5 / 2.6 Generation & Editing
    • Nano Banana Image Generation
    • Gemini Native Sync Image Generation
    • Seedream 5.0 Pro / 5.5 Image Generation
    • Midjourney Image Generation
  • Videos
    • Seedance 2 Video Generation
    • Omni Video Generation
    • Seedance 2.5 Video Generation
    • MiniMax H3 Video Generation
    • WAN 3.0 Video Generation
    • Muse Video Generation
    • Seedance Asset Registration
    • Gemini Omni 1.2 Flash Video Generation
    • Seedance Volcengine Native Video Generation
    • MAGI-2 Video Generation
  • Text Models
    • Claude Desktop (CC Switch) Setup Guide
    • Codex in ChatGPT Desktop Setup Guide
    • Gemini Text Models (Native Format)
    • Text & Chat APIs (OpenAI / Claude)
  • Audio
    • Gemini Text-to-Speech (TTS)
  1. Audio

Gemini Text-to-Speech (TTS)

Synthesize speech from text using gemini-3.8-flash-tts over the native Gemini endpoint. Requests return audio synchronously—there is no task ID or polling.
Model availability is determined by the live GET /v1/models response for your API key. Do not submit synthesis requests if the model does not appear in that list.

Endpoint & Authentication#

Authenticate with your Brioi API key via Authorization: Bearer, x-goog-api-key, or the ?key= query parameter. Only the native Gemini generateContent format is supported; OpenAI formats (/v1/chat/completions, /v1/audio/speech) are not available.
This endpoint extends the native Gemini payload with a part-level speech_metadata object for vocal style and speaker assignment. Official Google SDKs do not generate speech_metadata automatically, so include it manually in your JSON payload. Multi-speaker dialogue requires speech_metadata.speaker on every part—prefixing speaker names inside text (such as "Alex: ...") cannot substitute for it.

Billing#

Billed per request: each successful call counts as one request regardless of text length or audio duration. Failed requests are not charged. Submitting one line of dialogue per request is recommended.

Request Schema#

FieldTypeRequiredDescription
contentsarrayYesMust contain a single content item.
contents[].rolestringNoSet to user.
contents[].parts[].textstringYesText to speak aloud. Use one text part for single-speaker synthesis, or one part per line for multi-speaker dialogue.
contents[].parts[].speech_metadata.stylestringNoVocal delivery prompt, e.g. "tearful" or "low, restrained tone". Affects delivery only and is not spoken aloud.
contents[].parts[].speech_metadata.speakerstringConditionalRequired for multi-speaker dialogue. Speaker identifier for this line; must match a speaker entry in multiSpeakerVoiceConfig.
generationConfig.responseModalitiesstring[]YesMust be ["AUDIO"].
generationConfig.speechConfig.voiceConfig.prebuiltVoiceConfig.voiceNamestringConditionalRequired for single-speaker synthesis. Voice name from the list below; mutually exclusive with multiSpeakerVoiceConfig.
generationConfig.speechConfig.multiSpeakerVoiceConfig.speakerVoiceConfigsarrayConditionalRequired for multi-speaker dialogue. One entry per speaker with speaker and voiceConfig.prebuiltVoiceConfig.voiceName; mutually exclusive with voiceConfig.

Prebuilt Voices#

30 built-in voices are supported (voice cloning is not supported). Voices are language-independent—the same voice can speak English, Chinese, Japanese, Korean, and more.
Zephyr, Puck, Charon, Kore, Fenrir, Leda, Orus, Aoede, Callirrhoe, Autonoe, Enceladus, Iapetus, Umbriel, Algieba, Despina, Erinome, Algenib, Rasalgethi, Laomedeia, Achernar, Alnilam, Schedar, Gacrux, Pulcherrima, Achird, Zubenelgenubi, Vindemiatrix, Sadachbia, Sadaltager, Sulafat

Single-Speaker Example#

Multi-Speaker Dialogue Example#

Synthesize an entire dialogue exchange in a single request (still billed as one call): place each spoken turn in its own part with speech_metadata.speaker, and assign each speaker a voice in multiSpeakerVoiceConfig.
The response contains a single continuous audio clip for the full exchange rather than separate per-line files. When you need line-by-line timeline alignment (for example, dubbing over video), submit one line per request.

Response & Audio Conversion#

{
  "candidates": [{
    "content": {
      "role": "model",
      "parts": [{
        "inlineData": {
          "mimeType": "audio/l16; rate=24000; channels=1",
          "data": "BASE64_PCM_DATA"
        }
      }]
    },
    "finishReason": "STOP"
  }],
  "usageMetadata": {"promptTokenCount": 12, "candidatesTokenCount": 78, "totalTokenCount": 90},
  "modelVersion": "gemini-3.8-flash-tts"
}
inlineData.data is base64-encoded raw PCM (24000 Hz, mono, 16-bit signed little-endian) with no WAV header, so it cannot be played directly as .wav or .mp3. Convert it using either approach below:
Convert to WAV in Python:
Convert decoded raw PCM to MP3 with ffmpeg:

Limits & Error Handling#

When multiSpeakerVoiceConfig is used, every text part must include speech_metadata.speaker; otherwise the API returns 400.
Put delivery cues in speech_metadata.style, not inside text—cues placed inside text may be read aloud.
Synchronous synthesis blocks until generation completes (typically a few seconds up to ~20 seconds). If a client times out, do not blindly resubmit; record the X-Oneapi-Request-Id response header and error details first.
HTTP status codes: 400 invalid parameters, 401 missing or invalid API key, 403 insufficient balance/quota or missing model permission, 429 rate limit exceeded, 503 service temporarily unavailable, 500 / 502 transient server error.
Modified at 2026-12-04 07:58:01
Previous
Text & Chat APIs (OpenAI / Claude)
Built with