Saltar para o conteúdo principal

Introdução

The Text-to-Speech (TTS) API is based on advanced generative AI models that can convert input text into realistic speech audio. It suporta a variety of use cases:
  • Narrating written blog articles
  • Gerando speech audio in multiple languages
  • Providing real-time audio output streams

Modelos Disponíveis

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 é recomendado
  5. For scenarios requiring multi-speaker dialogues, the Gemini TTS models are recommended

API Endpoint

Request URL

Headers da Requisição

Parâmetros da Requisição

Standard TTS Parameters

The standard parameters applicable to o seguinte 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

Suporta o seguinte 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

Suporta o seguinte 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. Você pode provide guidance no input or instructions parameters.

Single Speaker Style Control

Multi-Speaker Style Control

Prompt Structure Recommendations

For best results, você pode use o seguinte structured prompt format:

Supported Languages

The TTS models automatically detect the input language. O seguinte 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

Limitações

  • 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)

Perguntas Frequentes

Q: How do I escolha 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: Suporta controlling voice style through natural language prompts, suporta multiple speakers, but only WAV/PCM formats
  • OpenAI TTS: Suporta 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 no instructions:

Q: Is streaming output supported?

Atualmente, the TTS API returns complete audio files and não suporta streaming output.

Última atualização: 2026-06-01