Probar un cuaderno de Colab
|
Ver cuaderno en GitHub
|
Text-to-Speech Gemini-TTS es la última evolución de nuestra tecnología Text-to-Speech, que va más allá de la naturalidad para ofrecer un control granular sobre el audio generado mediante peticiones basadas en texto. Con Gemini TTS, puedes sintetizar voz a partir de fragmentos cortos o narraciones largas, y dictar con precisión el estilo, el acento, el ritmo, el tono e incluso la expresión emocional, todo ello mediante peticiones en lenguaje natural.
Las funciones de Gemini TTS son compatibles con lo siguiente:
gemini-2.5-flash-preview-tts: La versión preliminar de Gemini 2.5 Flash es ideal para aplicaciones cotidianas rentables.gemini-2.5-pro-preview-tts: La versión preliminar de Gemini 2.5 Pro es adecuada para la generación de voz controlable (TTS) y para la calidad de vanguardia de las peticiones complejas.
| Modelo | Optimizado para | Modalidad de entrada | Modalidad de salida | Un interlocutor |
|---|---|---|---|---|
| Gemini 2.5 Flash Preview TTS | Generación de audio de conversión de texto a voz con baja latencia, controlable y para uno o varios interlocutores para aplicaciones cotidianas rentables | Texto | Audio | ✔️ |
| Gemini 2.5 Pro Preview TTS | Alto control para flujos de trabajo estructurados, como la generación de pódcasts, audiolibros o asistencia al cliente, entre otros | Texto | Audio | ✔️ |
Entre los controles y las funciones adicionales se incluyen los siguientes:
Conversación natural: las interacciones de voz de una calidad extraordinaria, una expresividad más adecuada y una prosodia (patrones de ritmo) se ofrecen con una latencia muy baja para que puedas conversar con fluidez.
Control del estilo: mediante peticiones de lenguaje natural, puedes adaptar la conversación para que adopte acentos específicos y produzca una variedad de tonos y expresiones, incluido un susurro.
Rendimiento dinámico: estos modelos pueden dar vida al texto para ofrecer lecturas expresivas de poesía, noticias y narraciones atractivas. También pueden actuar con emociones concretas y producir acentos cuando se les pide.
Control mejorado del ritmo y la pronunciación: controlar la velocidad de entrega ayuda a mejorar la precisión de la pronunciación, incluidas palabras específicas.
Ejemplos
model: "gemini-2.5-pro-preview-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-preview-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-preview-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"
Consulta la sección Usar Gemini TTS para obtener información sobre cómo usar estas voces mediante programación.
Opciones de voz
Gemini TTS ofrece una amplia gama de opciones de voz similares a las voces en HD de Chirp 3, cada una con características distintas:
| Nombre | Sexo | Demostración |
|---|---|---|
| Achernar | Mujeres | |
| Achird | Hombres | |
| Algenib | Hombres | |
| Algieba | Hombres | |
| Alnilam | Hombres | |
| Aoede | Mujeres | |
| Autónoe | Mujeres | |
| Callirrhoe | Mujeres | |
| Charon | Hombres | |
| Despina | Mujeres | |
| Encélado | Hombres | |
| Erinome | Mujeres | |
| Fenrir | Hombres | |
| Gacrux | Mujeres | |
| Jápeto | Hombres | |
| Kore | Mujeres | |
| Laomedeia | Mujeres | |
| Leda | Mujeres | |
| Orus | Hombres | |
| Pulcherrima | Mujeres | |
| Puck | Hombres | |
| Rasalgethi | Hombres | |
| Sadachbia | Hombres | |
| Sadaltager | Hombres | |
| Schedar | Hombres | |
| Sulafat | Mujeres | |
| Umbriel | Hombres | |
| Vindemiatrix | Mujeres | |
| Zephyr | Mujeres | |
| Zubenelgenubi | Hombres |
Idiomas disponibles
Gemini TTS ofrece una amplia gama de opciones de voz similares a las voces en HD de Chirp 3, cada una con características distintas:
| Idioma | Código BCP-47 |
|---|---|
| Inglés (EE. UU.) | en-US |
Disponibilidad regional
Los modelos de Gemini TTS están disponibles en las siguientes Google Cloud regiones:
| Google Cloud zona | Preparación para el lanzamiento |
|---|---|
global |
Vista previa pública |
Formatos de salida admitidos
El formato de respuesta predeterminado es LINEAR16. Otros formatos admitidos son los siguientes:
| Método de la API | Formato |
|---|---|
batch |
ALAW, MULAW, MP3, OGG_OPUS y PCM |
Usar Gemini TTS
Descubre cómo usar los modelos de Gemini TTS para sintetizar la voz de un solo interlocutor.
Realizar una solicitud de conversión de texto a voz síncrona
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, model_name: str, output_filepath: str = "output.mp3"):
"""Synthesizes speech from the input text and saves it to an MP3 file.
Args:
prompt: Stylisting instructions on how to synthesize the content in
the text field.
text: The text to synthesize.
model_name: Gemini model to use. Currently, the available models are
gemini-2.5-flash-preview-tts and gemini-2.5-pro-preview-tts
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=model_name
)
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.
# Currently, the available models are gemini-2.5-flash-preview-tts and gemini-2.5-pro-preview-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-preview-tts"
},
"audioConfig": {
"audioEncoding": "LINEAR16"
}
}' \
"https://texttospeech.googleapis.com/v1/text:synthesize" \
| jq -r '.audioContent' | base64 -d | ffplay - -autoexit
Probar un cuaderno de Colab
Ver cuaderno en GitHub