Passer au contenu principal

Introduction

L’API Text-to-Speech (TTS) repose sur des modèles d’IA générative avancés capables de convertir le texte d’entrée en audio vocal réaliste. Elle prend en charge divers cas d’usage :
  • Narration d’articles de blog écrits
  • Génération d’audio vocal en plusieurs langues
  • Fourniture de flux de sortie audio en temps réel

Available Models

OpenAI Models

  • gpt-4o-audio-preview — OpenAI’s latest audio generation model, supporting conversational audio generation
  • gpt-4o-mini-tts — The preferred model for smart real-time applications, supporting advanced voice control and allowing various voice characteristics to be controlled via prompts:
    1. Accent
    2. Emotional range
    3. Intonation
    4. Impressions/Style
    5. Speed of speech
    6. Tone
    7. Whispering
  • tts-1-hd — The previous generation TTS model with high-definition audio quality
  • tts-1 — Standard TTS model, balancing quality and speed

Gemini Models

Performance Recommendations:
  1. For the fastest response time, it’s recommended to use wav or pcm as the response format
  2. For high-quality audio, use tts-1-hd
  3. For faster generation speed, use tts-1
  4. For smart voice applications, gpt-4o-mini-tts is recommended
  5. For scenarios requiring multi-speaker dialogues, the Gemini TTS models are recommended

API Endpoint

Request URL

Request Headers

Request Parameters

Standard TTS Parameters

The standard parameters applicable to the following TTS models: tts-1, tts-1-hd, gpt-4o-mini-tts, gemini-2.5-flash-preview-tts, and gemini-2.5-pro-preview-tts.

gpt-4o-audio-preview Parameters

Voice List

OpenAI Voices

Supports the following voice options:
  • alloy - Neutral, balanced
  • ash - Clear, professional
  • ballad - Warm, narrative
  • coral - Friendly, approachable
  • echo - Clear, bright
  • fable - Expressive, dramatic
  • onyx - Deep, authoritative
  • nova - Lively, energetic
  • sage - Mature, knowledgeable
  • shimmer - Soft, soothing
  • verse - Clear, versatile
  • marin - Natural, friendly
  • cedar - Stable, reliable

Gemini Voices

Supports the following 30 voice options:

Voice Mapping

When using Gemini models, if an OpenAI voice name is provided, the system will automatically map it to the corresponding Gemini voice:

Usage Examples

Standard TTS Model (OpenAI)

Gemini TTS Model (Single Speaker)

Gemini TTS Model (Multi-Speaker - Controlled by Prompts)

Python Example (OpenAI SDK)

Python Example (Gemini TTS)

Controlling Voice Style (Gemini Models)

Gemini TTS models support controlling voice style, tone, accent, and speed through natural language prompts. You can provide guidance in the input or instructions parameters.

Single Speaker Style Control

Multi-Speaker Style Control

Prompt Structure Recommendations

For best results, you can use the following structured prompt format:

Supported Languages

The TTS models automatically detect the input language. The following 24 languages are supported:

Response Formats

Audio Formats

Note: The Gemini model natively returns PCM format (24kHz, mono, 16-bit), and the system will automatically convert it to WAV format. For other formats, it’s recommended to use OpenAI models.

Response Body

On success, an audio stream (binary data) is returned, and Content-Type is set according to the response_format parameter. On failure, a JSON error message is returned:

Billing Information

The TTS API is billed based on the number of characters:
  • The character count of the input text is the billing unit
  • Different models have different price multipliers
  • Maximum input length: 4096 characters

Limitations

  • Maximum input length: 4096 characters
  • Gemini TTS models only support wav and pcm output formats
  • Gemini TTS models do not support the speed parameter (controlled through prompts)
  • Context window limit: 32k tokens (Gemini models)

Frequently Asked Questions

Q: How do I choose the right model?

  • Need quick generation → tts-1 or gemini-2.5-flash-preview-tts
  • Need high-quality audio → tts-1-hd
  • Need intelligent voice control → gpt-4o-mini-tts or Gemini TTS models
  • Need multi-speaker dialogues → Gemini TTS models

Q: What are the differences between Gemini TTS and OpenAI TTS?

  • Gemini TTS: Supports controlling voice style through natural language prompts, supports multiple speakers, but only WAV/PCM formats
  • OpenAI TTS: Supports multiple audio formats, has fixed voice options, and speed can be controlled via parameters

Q: How do I implement multi-speaker dialogues?

Use the Gemini TTS model, format the input as a dialogue, and specify the style for each speaker in the instructions:

Q: Is streaming output supported?

Currently, the TTS API returns complete audio files and does not support streaming output.

Dernière mise à jour : 2026-06-01