La replicación de voz te permite replicar las características vocales de un orador a partir de una muestra de audio corta con el endpoint de Voices de la API de Gemini (POST /v1beta/voices). Tanto Gemini 3.8 Flash TTS (gemini-3.8-flash-tts) como Gemini 3.8 Flash-Lite TTS (gemini-3.8-flash-lite-tts) admiten la replicación de voz.
La forma más rápida de replicar una voz, verificar el consentimiento y probarla es con la experiencia interactiva de replicación de voz en Google AI Studio. Puedes grabar o subir clips de referencia y consentimiento directamente en el navegador, obtener una vista previa de la voz y copiar el ID de voice_... resultante directamente en el código de tu aplicación.
Modos de almacenamiento con estado frente a modos de almacenamiento sin estado
La replicación de voz admite dos modos de almacenamiento cuando se llama a voices.create (POST /v1beta/voices), con el almacenamiento con estado habilitado de forma predeterminada:
- Almacenamiento con estado (
store=True, valor predeterminado recomendado): Google almacena tu perfil de voz verificado en tu proyecto y devuelve unvoice_id(replicated_voice.id, comovoice_abc123...) ligero y persistente. Puedes pasar estevoice_identre solicitudes y administrarlo convoices.list(),voices.get()yvoices.delete(). - Claves sin estado administradas por el cliente (
store=False, opcional): Para las cargas de trabajo que requieren persistencia nula del servidor de perfiles de voz biométricos, establecestore=False. La API devuelve unvoice_keyencriptado y autónomo (replicated_voice.key, que comienza convoicekey_...) que tu aplicación almacena de forma local y pasa directamente en las solicitudes de síntesis.
| Modo de almacenamiento | Identificador | Límite del proyecto | Retención (TTL) |
|---|---|---|---|
Voces con estado (store=True) |
voice_... |
200 voces por proyecto (compartidas entre las voces replicadas y las creadas con instrucciones) | 1 año |
Claves de voz sin estado (store=False) |
voicekey_... |
Administrado por el cliente | 7 días |
Requisitos de audio y consentimiento
Cada solicitud de replicación de CreateVoice requiere dos grabaciones de audio reales de la misma persona adulta (se recomienda WAV mono de 16 bits y 24 kHz):
- Audio de referencia (
source_audio): Un clip de 10 a 30 segundos de voz natural y clara del orador cuya voz deseas replicar. - Audio de consentimiento (
consent_audio): Una grabación del mismo orador que recita claramente la declaración de consentimiento obligatoria en uno de los idiomas admitidos (por ejemplo, en inglés): > "I am the owner of this voice and I consent to Google using this voice to > create a synthetic voice model."
Crea una voz replicada (predeterminada con estado)
Usa el SDK de IA generativa de Google (google-genai 2.25.0 o posterior / @google/genai 2.24.0 o posterior) o la API de REST con store=True para crear y guardar un perfil de voz replicado en tu proyecto:
Python
import base64
from google import genai
client = genai.Client()
with open("reference_speaker.wav", "rb") as f:
source_b64 = base64.b64encode(f.read()).decode("utf-8")
with open("speaker_consent.wav", "rb") as f:
consent_b64 = base64.b64encode(f.read()).decode("utf-8")
# Create a persistent replicated voice (store=True)
replicated_voice = client.voices.create(
store=True,
voice={
"model": "gemini-3.8-flash-tts",
"type": "replicated",
"display_name": "Custom Replicated Speaker",
"replicated": {
"source_audio": {
"mime_type": "audio/wav",
"data": source_b64,
},
"consent_audio": {
"mime_type": "audio/wav",
"data": consent_b64,
},
},
},
)
print(f"Created voice ID: {replicated_voice.id}")
JavaScript
import * as fs from "node:fs";
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI();
const sourceB64 = fs.readFileSync("reference_speaker.wav").toString("base64");
const consentB64 = fs.readFileSync("speaker_consent.wav").toString("base64");
// Create a persistent replicated voice (store: true)
const replicatedVoice = await ai.voices.create({
store: true,
voice: {
model: "gemini-3.8-flash-tts",
type: "replicated",
display_name: "Custom Replicated Speaker",
replicated: {
source_audio: {
mime_type: "audio/wav",
data: sourceB64,
},
consent_audio: {
mime_type: "audio/wav",
data: consentB64,
},
},
},
});
console.log(`Created voice ID: ${replicatedVoice.id}`);
REST
SOURCE_B64=$(base64 -w 0 reference_speaker.wav)
CONSENT_B64=$(base64 -w 0 speaker_consent.wav)
curl "https://generativelanguage.googleapis.com/v1beta/voices" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-X POST \
-d "{
\"store\": true,
\"voice\": {
\"model\": \"gemini-3.8-flash-tts\",
\"type\": \"replicated\",
\"display_name\": \"Custom Replicated Speaker\",
\"replicated\": {
\"source_audio\": {
\"mime_type\": \"audio/wav\",
\"data\": \"$SOURCE_B64\"
},
\"consent_audio\": {
\"mime_type\": \"audio/wav\",
\"data\": \"$CONSENT_B64\"
}
}
}
}"
Sintetiza la voz con tu voz replicada
Pasa el id (voice_...) que se devolvió en tu solicitud de síntesis:
Python
import base64
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-3.8-flash-tts",
input=[{
"type": "user_input",
"content": [{
"type": "text",
"text": (
"Hello! This audio was synthesized using a replicated"
" speaker voice."
),
"annotations": [{
"type": "speech_metadata",
"style": "warm and conversational",
}],
}],
}],
response_format={"type": "audio"},
generation_config={
"speech_config": [
{"voice": replicated_voice.id},
]
},
)
with open("replicated_speech.wav", "wb") as f:
f.write(base64.b64decode(interaction.output_audio.data))
JavaScript
import * as fs from "node:fs";
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI();
const interaction = await ai.interactions.create({
model: "gemini-3.8-flash-tts",
input: [{
type: "user_input",
content: [{
type: "text",
text: "Hello! This audio was synthesized using a replicated speaker voice.",
annotations: [{
type: "speech_metadata",
style: "warm and conversational",
}],
}],
}],
response_format: { type: "audio" },
generation_config: {
speech_config: [
{ voice: replicatedVoice.id },
],
},
});
fs.writeFileSync("replicated_speech.wav", Buffer.from(interaction.output_audio.data, "base64"));
REST
curl "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-X POST \
-d '{
"model": "gemini-3.8-flash-tts",
"input": [{
"type": "user_input",
"content": [{
"type": "text",
"text": "Hello! This audio was synthesized using a replicated speaker voice.",
"annotations": [{
"type": "speech_metadata",
"style": "warm and conversational"
}]
}]
}],
"response_format": {"type": "audio"},
"generation_config": {
"speech_config": [
{"voice": "voice_YOUR_REPLICATED_VOICE_ID"}
]
}
}'
Administra las voces replicadas almacenadas
Cuando se crean con store=True, tus voces replicadas se pueden enumerar, filtrar, inspeccionar y borrar a través de la API de Voices (consulta Biblioteca de voces extendida y filtrado para ver todos los parámetros de filtro):
Python
from google import genai
client = genai.Client()
# List stored replicated voices in your project
response = client.voices.list(type_=["replicated"])
for voice in response.voices or []:
print(voice.id, voice.display_name, voice.type)
# Retrieve a specific voice by ID
voice_details = client.voices.get(id=replicated_voice.id)
# Delete a stored replicated voice
client.voices.delete(id=replicated_voice.id)
JavaScript
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI();
// List stored replicated voices in your project
const response = await ai.voices.list({ type: ["replicated"] });
for (const voice of response.voices ?? []) {
console.log(voice.id, voice.display_name, voice.type);
}
// Retrieve a specific voice by ID
const voiceDetails = await ai.voices.get(replicatedVoice.id);
// Delete a stored replicated voice
await ai.voices.delete(replicatedVoice.id);
REST
# List stored replicated voices in your project
curl -G "https://generativelanguage.googleapis.com/v1beta/voices" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
--data-urlencode "type=replicated"
# Retrieve a specific voice by ID
curl "https://generativelanguage.googleapis.com/v1beta/voices/voice_YOUR_REPLICATED_VOICE_ID" \
-H "x-goog-api-key: $GEMINI_API_KEY"
# Delete a stored replicated voice
curl -X DELETE "https://generativelanguage.googleapis.com/v1beta/voices/voice_YOUR_REPLICATED_VOICE_ID" \
-H "x-goog-api-key: $GEMINI_API_KEY"
Opción: Claves de voz administradas por el cliente sin estado (store=False)
Si tu aplicación no requiere persistencia del servidor de los perfiles de voz, configura store=False cuando crees la voz replicada. La API devuelve un voice_key (replicated_voice.key, que comienza con voicekey_...) encriptado que almacenas del lado del cliente y pasas directamente a cualquier lugar donde se acepte un ID de voice:
Python
import base64
from google import genai
client = genai.Client()
with open("reference_speaker.wav", "rb") as f:
source_b64 = base64.b64encode(f.read()).decode("utf-8")
with open("speaker_consent.wav", "rb") as f:
consent_b64 = base64.b64encode(f.read()).decode("utf-8")
# Create a stateless client-managed voice key (store=False)
replicated_voice = client.voices.create(
store=False,
voice={
"model": "gemini-3.8-flash-tts",
"type": "replicated",
"replicated": {
"source_audio": {"mime_type": "audio/wav", "data": source_b64},
"consent_audio": {"mime_type": "audio/wav", "data": consent_b64},
},
},
)
# Pass replicated_voice.key ("voicekey_...") directly as the speaker voice
interaction = client.interactions.create(
model="gemini-3.8-flash-tts",
input=[{
"type": "user_input",
"content": [{
"type": "text",
"text": "Hello! This audio uses a stateless client-managed voice key.",
"annotations": [{
"type": "speech_metadata",
"style": "warm and conversational",
}],
}],
}],
response_format={"type": "audio"},
generation_config={
"speech_config": [
{"voice": replicated_voice.key},
]
},
)
JavaScript
import * as fs from "node:fs";
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI();
const sourceB64 = fs.readFileSync("reference_speaker.wav").toString("base64");
const consentB64 = fs.readFileSync("speaker_consent.wav").toString("base64");
// Create a stateless client-managed voice key (store: false)
const replicatedVoice = await ai.voices.create({
store: false,
voice: {
model: "gemini-3.8-flash-tts",
type: "replicated",
replicated: {
source_audio: { mime_type: "audio/wav", data: sourceB64 },
consent_audio: { mime_type: "audio/wav", data: consentB64 },
},
},
});
// Pass replicatedVoice.key ("voicekey_...") directly as the speaker voice
const interaction = await ai.interactions.create({
model: "gemini-3.8-flash-tts",
input: [{
type: "user_input",
content: [{
type: "text",
text: "Hello! This audio uses a stateless client-managed voice key.",
annotations: [{
type: "speech_metadata",
style: "warm and conversational",
}],
}],
}],
response_format: { type: "audio" },
generation_config: {
speech_config: [
{ voice: replicatedVoice.key },
],
},
});
REST
SOURCE_B64=$(base64 -w 0 reference_speaker.wav)
CONSENT_B64=$(base64 -w 0 speaker_consent.wav)
curl "https://generativelanguage.googleapis.com/v1beta/voices" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-X POST \
-d "{
\"store\": false,
\"voice\": {
\"model\": \"gemini-3.8-flash-tts\",
\"type\": \"replicated\",
\"replicated\": {
\"source_audio\": {\"mime_type\": \"audio/wav\", \"data\": \"$SOURCE_B64\"},
\"consent_audio\": {\"mime_type\": \"audio/wav\", \"data\": \"$CONSENT_B64\"}
}
}
}"
Frases de consentimiento admitidas por idioma
El audio de consentimiento debe recitar claramente la declaración exacta en uno de los 30 códigos de idioma admitidos:
| Idioma | Configuración regional (lang_id) |
Declaración de consentimiento textual |
|---|---|---|
| Árabe | ar-XA |
أنا مالك هذا الصوت وأوافق على أن تستخدم Google هذا الصوت لإنشاء نموذج صوتي اصطناعي. |
| Bengalí | bn-IN |
আমি এই ভয়েসের মালিক এবং আমি একটি সিন্থেটিক ভয়েস মডেল তৈরি করতে এই ভয়েস ব্যবহার করে Google-এর সাথে সম্মতি দিচ্ছি। |
| Chino (simplificado) | zh-CN |
我是此声音的拥有者并授权谷歌使用此声音创建语音合成模型 |
| Holandés | nl-NL |
Ik ben de eigenaar van deze stem en ik geef Google toestemming om deze stem te gebruiken om een synthetisch stemmodel te maken. |
| Inglés (EE.UU.) | en-US |
I am the owner of this voice and I consent to Google using this voice to create a synthetic voice model. |
| Inglés (Reino Unido) | en-GB |
I am the owner of this voice and I consent to Google using this voice to create a synthetic voice model. |
| English (India) | en-IN |
I am the owner of this voice and I consent to Google using this voice to create a synthetic voice model. |
| Inglés (Australia) | en-AU |
I am the owner of this voice and I consent to Google using this voice to create a synthetic voice model. |
| French (France) | fr-FR |
Je suis le propriétaire de cette voix et j'autorise Google à utiliser cette voix pour créer un modèle de voix synthétique. |
| Francés (Canadá) | fr-CA |
Je suis le propriétaire de cette voix et j'autorise Google à utiliser cette voix pour créer un modèle de voix synthétique. |
| Alemán | de-DE |
Ich bin der Eigentümer dieser Stimme und bin damit einverstanden, dass Google diese Stimme zur Erstellung eines synthetischen Stimmmodells verwendet. |
| Guyaratí | gu-IN |
હું આ વોઈસનો માલિક છું અને સિન્થેટિક વોઈસ મોડલ બનાવવા માટે આ વોઈસનો ઉપયોગ કરીને google ને હું સંમતિ આપું છું |
| Hindi | hi-IN |
मैं इस आवाज का मालिक हूं और मैं सिंथेटिक आवाज मॉडल बनाने के लिए Google को इस आवाज का उपयोग करने की सहमति देता हूं |
| Indonesio | id-ID |
Saya pemilik suara ini dan saya menyetujui Google menggunakan suara ini untuk membuat model suara sintetis. |
| Italiano | it-IT |
Sono il proprietario di questa voce e acconsento che Google la utilizzi per creare un modello di voce sintetica. |
| Japonés | ja-JP |
私はこの音声の所有者であり、Googleがこの音声を使用して音声合成モデルを作成することを承認します。 |
| Canarés | kn-IN |
ನಾನು ಈ ಧ್ವನಿಯ ಮಾಲಿಕ ಮತ್ತು ಸಂಶ್ಲೇಷಿತ ಧ್ವನಿ ಮಾದರಿಯನ್ನು ರಚಿಸಲು ಈ ಧ್ವನಿಯನ್ನು ಬಳಸಿಕೊಂಡುಗೂಗಲ್ ಗೆ ನಾನು ಸಮ್ಮತಿಸುತ್ತೇನೆ. |
| Coreano | ko-KR |
나는 이 음성의 소유자이며 구글이 이 음성을 사용하여 음성 합성 모델을 생성할 것을 허용합니다. |
| Malabar | ml-IN |
ഈ ശബ്ദത്തിന്റെ ഉടമ ഞാനാണ്, ഒരു സിന്തറ്റിക് വോയ്സ് മോഡൽ സൃഷ്ടിക്കാൻ ഈ ശബ്ദം ഉപയോഗിക്കുന്നതിന് ഞാൻ Google-ന് സമ്മതം നൽകുന്നു. |
| Maratí | mr-IN |
मी या आवाजाचा मालक आहे आणि सिंथेटिक व्हॉइस मॉडेल तयार करण्यासाठी हा आवाज वापरण्यासाठी मी Google ला संमती देतो |
| Polaco | pl-PL |
Jestem właścicielem tego głosu i wyrażam zgodę na wykorzystanie go przez Google w celu utworzenia syntetycznego modelu głosu. |
| Portugués (Brasil) | pt-BR |
Eu sou o proprietário desta voz e autorizo o Google a usá-la para criar um modelo de voz sintética. |
| Ruso | ru-RU |
Я являюсь владельцем этого голоса и даю согласие Google на использование этого голоса для создания модели синтетического голоса. |
| Spanish (Spain) | es-ES |
Soy el propietario de esta voz y doy mi consentimiento para que Google la utilice para crear un modelo de voz sintética. |
| Español (EE.UU.) | es-US |
Soy el propietario de esta voz y doy mi consentimiento para que Google la utilice para crear un modelo de voz sintética. |
| Tamil | ta-IN |
நான் இந்த குரலின் உரிமையாளர் மற்றும் செயற்கை குரல் மாதிரியை உருவாக்க இந்த குரலை பயன்படுத்த குகல்க்கு நான் ஒப்புக்கொள்கிறேன். |
| Télugu | te-IN |
నేను ఈ వాయిస్ యజమానిని మరియు సింతటిక్ వాయిస్ మోడల్ ని రూపొందించడానికి ఈ వాయిస్ ని ఉపయోగించడానికి googleకి నేను సమ్మతిస్తున్నాను. |
| Tailandés | th-TH |
ฉันเป็นเจ้าของเสียงนี้ และฉันยินยอมให้ Google ใช้เสียงนี้เพื่อสร้างแบบจำลองเสียงสังเคราะห์ |
| Turco | tr-TR |
Bu sesin sahibi benim ve Google'ın bu sesi kullanarak sentetik bir ses modeli oluşturmasına izin veriyorum. |
| Vietnamita | vi-VN |
Tôi là chủ sở hữu giọng nói này và tôi đồng ý cho Google sử dụng giọng nói này để tạo mô hình giọng nói tổng hợp. |
Prácticas recomendadas para grabar audio de referencia
- Graba en un entorno tranquilo: Minimiza el eco de la habitación, el ruido de fondo, la música y las voces superpuestas.
- Condiciones de grabación coincidentes: Graba
source_audioyconsent_audiocon el mismo micrófono y en el mismo entorno acústico para que la verificación del orador se realice correctamente. - Convierte a WAV mono de 24 kHz: Para obtener los mejores resultados, vuelve a muestrear el audio de entrada a WAV mono de PCM de 16 bits y 24 kHz antes de codificarlo.
¿Qué sigue?
- Obtén más información para crear arquetipos personalizados a partir de descripciones de texto en Diseño de voz.
- Explora el diseño a nivel de turnos, las etiquetas intercaladas y el diálogo de varios oradores en la guía de Text-to-Speech.