La voix personnalisée instantanée de Text-to-Speech permet aux utilisateurs de créer des modèles de voix personnalisées en entraînant un modèle avec leurs propres enregistrements audio de haute qualité. Cet outil permet de générer rapidement des voix personnalisées, qui peuvent ensuite être utilisées pour synthétiser de l'audio à l'aide de l'API Cloud TTS, compatible à la fois avec le streaming et les textes longs.
![]() |
![]() |
Langues disponibles
Les voix personnalisées instantanées sont disponibles dans les langues suivantes :
Langue | Code BCP-47 | Déclaration de consentement |
---|---|---|
Arabe (XA) | ar-XA | .أنا مالك هذا الصوت وأوافق على أن تستخدم Google هذا الصوت لإنشاء نموذج صوتي اصطناعي |
Bengali (Inde) | bn-IN | আমি এই ভয়েসের মালিক এবং আমি একটি সিন্থেটিক ভয়েস মডেল তৈরি করতে এই ভয়েস ব্যবহার করে Google-এর সাথে সম্মতি দিচ্ছি। |
Chinois (Chine) | cmn-CN | 我是此声音的拥有者并授权谷歌使用此声音创建语音合成模型 |
Anglais (Australie) | en-AU | I am the owner of this voice and I consent to Google using this voice to create a synthetic voice model. |
Anglais (Inde) | en-IN | I am the owner of this voice and I consent to Google using this voice to create a synthetic voice model. |
Anglais (Royaume-Uni) | en-GB | I am the owner of this voice and I consent to Google using this voice to create a synthetic voice model. |
Anglais (États-Unis) | en-US | I am the owner of this voice and I consent to Google using this voice to create a synthetic voice model. |
Français (Canada) | fr-CA | Je suis le propriétaire de cette voix et j'autorise Google à l'utiliser pour créer un modèle de voix synthétique. |
Français (France) | fr-FR | Je suis le propriétaire de cette voix et j'autorise Google à l'utiliser pour créer un modèle de voix synthétique. |
Allemand (Allemagne) | de-DE | Ich bin der Eigentümer dieser Stimme und bin damit einverstanden, dass Google diese Stimme zur Erstellung eines synthetischen Stimmmodells verwendet. |
Gujarati (Inde) | gu-IN | હું આ વોઈસનો માલિક છું અને સિન્થેટિક વોઈસ મોડલ બનાવવા માટે આ વોઈસનો ઉપયોગ કરીને google ને હું સંમતિ આપું છું |
Hindi (Inde) | hi-IN | मैं इस आवाज का मालिक हूं और मैं सिंथेटिक आवाज मॉडल बनाने के लिए Google को इस आवाज का उपयोग करने की सहमति देता हूं |
Indonésien (Indonésie) | id-ID | Saya pemilik suara ini dan saya menyetujui Google menggunakan suara ini untuk membuat model suara sintetis. |
Italien (Italie) | it-IT | Sono il proprietario di questa voce e acconsento che Google la utilizzi per creare un modello di voce sintetica. |
Japonais (Japon) | ja-JP | 私はこの音声の所有者であり、Googleがこの音声を使用して音声合成モデルを作成することを承認します。 |
Kannada (Inde) | kn-IN | ನಾನು ಈ ಧ್ವನಿಯ ಮಾಲಿಕ ಮತ್ತು ಸಂಶ್ಲೇಷಿತ ಧ್ವನಿ ಮಾದರಿಯನ್ನು ರಚಿಸಲು ಈ ಧ್ವನಿಯನ್ನು ಬಳಸಿಕೊಂಡುಗೂಗಲ್ ಗೆ ನಾನು ಸಮ್ಮತಿಸುತ್ತೇನೆ. |
Coréen (Corée) | ko-KR | 나는 이 음성의 소유자이며 구글이 이 음성을 사용하여 음성 합성 모델을 생성할 것을 허용합니다. |
Malayalam (Inde) | ml-IN | ഈ ശബ്ദത്തിന്റെ ഉടമ ഞാനാണ്, ഒരു സിന്തറ്റിക് വോയ്സ് മോഡൽ സൃഷ്ടിക്കാൻ ഈ ശബ്ദം ഉപയോഗിക്കുന്നതിന് ഞാൻ Google-ന് സമ്മതം നൽകുന്നു." |
Marathi (Inde) | mr-IN | मी या आवाजाचा मालक आहे आणि सिंथेटिक व्हॉइस मॉडेल तयार करण्यासाठी हा आवाज वापरण्यासाठी मी Google ला संमती देतो |
Néerlandais (Pays-Bas) | 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. |
Polonais (Pologne) | 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. |
Portugais (Brésil) | pt-BR | Eu sou o proprietário desta voz e autorizo o Google a usá-la para criar um modelo de voz sintética. |
Russe (Russie) | ru-RU | Я являюсь владельцем этого голоса и даю согласие Google на использование этого голоса для создания модели синтетического голоса. |
Tamoul (Inde) | ta-IN | நான் இந்த குரலின் உரிமையாளர் மற்றும் செயற்கை குரல் மாதிரியை உருவாக்க இந்த குரலை பயன்படுத்த குகல்க்கு நான் ஒப்புக்கொள்கிறேன். |
Télougou (Inde) | te-IN | నేను ఈ వాయిస్ యజమానిని మరియు సింతటిక్ వాయిస్ మోడల్ ని రూపొందించడానికి ఈ వాయిస్ ని ఉపయోగించడానికి googleకి నేను సమ్మతిస్తున్నాను. |
Thaï (Thaïlande) | th-TH | ฉันเป็นเจ้าของเสียงนี้ และฉันยินยอมให้ Google ใช้เสียงนี้เพื่อสร้างแบบจำลองเสียงสังเคราะห์ |
Turc (Turquie) | tr-TR | Bu sesin sahibi benim ve Google'ın bu sesi kullanarak sentetik bir ses modeli oluşturmasına izin veriyorum. |
Vietnamien (Viêt Nam) | 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. |
Espagnol (Espagne) | 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. |
Espagnol (États-Unis) | 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. |
Disponibilité en fonction des régions
La voix personnalisée instantanée est disponible dans les régions Google Cloudsuivantes :
ZoneGoogle Cloud | Méthode acceptée | Disponibilité pour le lancement |
---|---|---|
global |
Création, synthèse | Version Preview privée |
us |
Synthèse | Version Preview privée |
eu |
Synthèse | Version Preview privée |
asia-southeast1 |
Synthèse | Version Preview privée |
Formats de sortie acceptés
Le format de réponse par défaut est LINEAR16, mais d'autres formats sont acceptés, y compris :
Méthode API | Format |
---|---|
streaming |
ALAW, MULAW, OGG_OPUS et PCM |
batch |
ALAW, MULAW, MP3, OGG_OPUS et PCM |
Compatibilité des fonctionnalités et limites
Fonctionnalité | Assistance | Description |
---|---|---|
SSML | Non | Balises SSML pour personnaliser le son synthétique |
Requêtes textuelles | Version expérimentale | Utilisez la ponctuation, les pauses et les hésitations pour ajouter un flux et un rythme naturels à Text-to-Speech. |
Codes temporels | Non | Codes temporels au niveau du mot |
Mettre en veille des balises | Non | Ajouter des pauses à la demande dans l'audio synthétisé |
Contrôle du rythme | Non | Ajustez la vitesse de l'audio synthétisé, de 0,25x à 2x. |
Contrôle de la prononciation | Non | Prononciations personnalisées de mots ou d'expressions à l'aide de l'encodage phonétique IPA ou X-SAMPA |
Utiliser Chirp 3 : voix personnalisée instantanée
Les sections suivantes expliquent comment utiliser les fonctionnalités de Chirp 3 : voix personnalisée instantanée dans l'API Text-to-Speech.
Enregistrer le consentement et l'audio de référence
Enregistrez la déclaration de consentement : pour respecter les consignes légales et éthiques concernant la voix personnalisée instantanée, enregistrez la déclaration de consentement requise dans la langue appropriée, au format WAV mono, avec un encodage LINEAR16 et un taux d'échantillonnage de 24 kHz. ( : Je suis le propriétaire de cette voix et j'accepte que Google l'utilise pour créer un modèle de voix synthétique.)
Enregistrez l'audio de référence : utilisez le micro de votre ordinateur pour enregistrer jusqu'à 10 secondes d'audio au format WAV mono encodé au format LINEAR16 avec un taux d'échantillonnage de 24 kHz. Il ne doit pas y avoir de bruit de fond pendant l'enregistrement. Enregistrez le consentement et l'audio de référence dans le même environnement.
Stockez les fichiers audio : sauvegardez les fichiers audio enregistrés dans un emplacement Cloud Storage désigné.
Créer une voix personnalisée instantanée à l'aide de l'API REST
Une voix personnalisée instantanée se présente sous la forme d'une clé de clonage vocal, qui est une représentation sous forme de chaîne de texte de vos données vocales.
Points importants à retenir
Voici quelques points importants à connaître sur la création d'une voix personnalisée :
- Vous pouvez créer un nombre illimité de clés de clonage vocal, car elles sont stockées côté client et fournies par requête.
- La même clé de clonage vocal peut être utilisée par plusieurs clients ou appareils en même temps.
- Vous pouvez créer 10 clés de clonage vocal par minute et par projet. Pour en savoir plus, consultez la section Limite de requêtes.
- Vous ne pouvez pas utiliser de script de consentement personnalisé à la place de celui par défaut. Vous devez utiliser le script de consentement fourni dans Langues disponibles.
import requests, os, json
def create_instant_custom_voice_key(
access_token, project_id, reference_audio_bytes, consent_audio_bytes
):
url = "https://texttospeech.googleapis.com/v1beta1/voices:generateVoiceCloningKey"
request_body = {
"reference_audio": {
"audio_config": {"audio_encoding": "LINEAR16", "sample_rate_hertz": 24000},
"content": reference_audio_bytes,
},
"voice_talent_consent": {
"audio_config": {"audio_encoding": "LINEAR16", "sample_rate_hertz": 24000},
"content": consent_audio_bytes,
},
"consent_script": "I am the owner of this voice and I consent to Google using this voice to create a synthetic voice model.",
"language_code": "en-US",
}
try:
headers = {
"Authorization": f"Bearer {access_token}",
"x-goog-user-project": project_id,
"Content-Type": "application/json; charset=utf-8",
}
response = requests.post(url, headers=headers, json=request_body)
response.raise_for_status()
response_json = response.json()
return response_json.get("voiceCloningKey")
except requests.exceptions.RequestException as e:
print(f"Error making API request: {e}")
except json.JSONDecodeError as e:
print(f"Error decoding JSON response: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
Synthétiser avec une voix personnalisée instantanée à l'aide de l'API REST
Utilisez la clé de clonage de voix pour synthétiser des contenus audio à l'aide de l'API REST.
import requests, os, json, base64
from IPython.display import Audio, display
def synthesize_text_with_cloned_voice(access_token, project_id, voice_key, text):
url = "https://texttospeech.googleapis.com/v1beta1/text:synthesize"
request_body = {
"input": {
"text": text
},
"voice": {
"language_code": "en-US",
"voice_clone": {
"voice_cloning_key": voice_key,
}
},
"audioConfig": {
"audioEncoding": "LINEAR16",
"sample_rate_hertz": 24000
}
}
try:
headers = {
"Authorization": f"Bearer {access_token}",
"x-goog-user-project": project_id,
"Content-Type": "application/json; charset=utf-8"
}
response = requests.post(url, headers=headers, json=request_body)
response.raise_for_status()
response_json = response.json()
audio_content = response_json.get("audioContent")
if audio_content:
display(Audio(base64.b64decode(audio_content), rate=24000))
else:
print("Error: Audio content not found in the response.")
print(response_json)
except requests.exceptions.RequestException as e:
print(f"Error making API request: {e}")
except json.JSONDecodeError as e:
print(f"Error decoding JSON response: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
Synthétiser avec une voix personnalisée instantanée à l'aide de la bibliothèque cliente Python
Cet exemple utilise la bibliothèque cliente Python pour effectuer la synthèse vocale personnalisée instantanée, à l'aide d'une clé de clonage vocal enregistrée dans le fichier voice_cloning_key.txt
. Pour générer une clé de clonage vocal, consultez Créer une voix personnalisée instantanée à l'aide de l'API REST.
from google.cloud import texttospeech
from google.cloud.texttospeech_v1beta1.services.text_to_speech import client
def perform_voice_cloning(
voice_cloning_key: str,
transcript: str,
language_code: str,
synthesis_output_path: str,
tts_client: client.TextToSpeechClient,
) -> None:
"""Perform voice cloning and write output to a file.
Args:
voice_cloning_key: The voice cloning key.
transcript: The transcript to synthesize.
language_code: The language code.
synthesis_output_path: The synthesis audio output path.
tts_client: The TTS client to use.
"""
voice_clone_params = texttospeech.VoiceCloneParams(
voice_cloning_key=voice_cloning_key
)
voice = texttospeech.VoiceSelectionParams(
language_code=language_code, voice_clone=voice_clone_params
)
request = texttospeech.SynthesizeSpeechRequest(
input=texttospeech.SynthesisInput(text=transcript),
voice=voice,
audio_config=texttospeech.AudioConfig(
audio_encoding=texttospeech.AudioEncoding.LINEAR16,
sample_rate_hertz=24000,
),
)
response = tts_client.synthesize_speech(request)
with open(synthesis_output_path, 'wb') as out:
out.write(response.audio_content)
print(f'Audio content written to file {synthesis_output_path}.')
if __name__ == '__main__':
client = texttospeech.TextToSpeechClient()
with open('voice_cloning_key.txt', 'r') as f:
key = f.read()
perform_voice_cloning(
voice_cloning_key=key,
transcript='Hello world!',
language_code='en-US',
synthesis_output_path='/tmp/output.wav',
tts_client=client,
)
Synthétiser en flux continu avec une voix personnalisée instantanée à l'aide de la bibliothèque cliente Python
Cet exemple utilise la bibliothèque cliente Python pour effectuer la synthèse d'une voix personnalisée instantanée en flux continu, à l'aide d'une clé de clonage vocal enregistrée dans voice_cloning_key.txt
.
Pour générer une clé de clonage vocal, consultez Créer une voix personnalisée instantanée à l'aide de l'API REST.
import io
import wave
from google.cloud import texttospeech
from google.cloud.texttospeech_v1beta1.services.text_to_speech import client
def perform_voice_cloning_with_simulated_streaming(
voice_cloning_key: str,
simulated_streamed_text: list[str],
language_code: str,
synthesis_output_path: str,
tts_client: client.TextToSpeechClient,
) -> None:
"""Perform voice cloning for a given reference audio, voice talent consent, and consent script.
Args:
voice_cloning_key: The voice cloning key.
simulated_streamed_text: The list of transcripts to synthesize, where each
item represents a chunk of streamed text. This is used to simulate
streamed text input and is not meant to be representative of real-world
streaming usage.
language_code: The language code.
synthesis_output_path: The path to write the synthesis audio output to.
tts_client: The TTS client to use.
"""
voice_clone_params = texttospeech.VoiceCloneParams(
voice_cloning_key=voice_cloning_key
)
streaming_config = texttospeech.StreamingSynthesizeConfig(
voice=texttospeech.VoiceSelectionParams(
language_code=language_code, voice_clone=voice_clone_params
),
streaming_audio_config=texttospeech.StreamingAudioConfig(
audio_encoding=texttospeech.AudioEncoding.PCM,
sample_rate_hertz=24000,
),
)
config_request = texttospeech.StreamingSynthesizeRequest(
streaming_config=streaming_config
)
# Request generator. Consider using Gemini or another LLM with output
# streaming as a generator.
def request_generator():
yield config_request
for text in simulated_streamed_text:
yield texttospeech.StreamingSynthesizeRequest(
input=texttospeech.StreamingSynthesisInput(text=text)
)
streaming_responses = tts_client.streaming_synthesize(request_generator())
audio_buffer = io.BytesIO()
for response in streaming_responses:
print(f'Audio content size in bytes is: {len(response.audio_content)}')
audio_buffer.write(response.audio_content)
# Write collected audio outputs to a WAV file.
with wave.open(synthesis_output_path, 'wb') as wav_file:
wav_file.setnchannels(1)
wav_file.setsampwidth(2)
wav_file.setframerate(24000)
wav_file.writeframes(audio_buffer.getvalue())
print(f'Audio content written to file {synthesis_output_path}.')
if __name__ == '__main__':
client = texttospeech.TextToSpeechClient()
with open('voice_cloning_key.txt', 'r') as f:
key = f.read()
perform_voice_cloning_with_simulated_streaming(
voice_cloning_key=key,
simulated_streamed_text=[
'Hello world!',
'This is the second text chunk.',
'This simulates streaming text for synthesis.',
],
language_code='en-US',
synthesis_output_path='streaming_output.wav',
tts_client=client,
)