United121
United121

Reputation: 729

How to call google TTS Wavenet voice with python

I am using the TTS library from Google. My code in Python is almost the same as their sample code. But I cannot manage to call their service with WaveNet voice enabled (I am aiming to non-english language but which is also shown as WaveNet voice supported). My assumption is that it will be based on this param. But I cannot see its use anywhere.

Upvotes: 2

Views: 2408

Answers (1)

United121
United121

Reputation: 729

Figure it out:

# Build the voice request, select the language code ("en-US") and the ssml
# voice gender ("neutral")
voice = texttospeech.types.VoiceSelectionParams(
    language_code='cs-CZ',
    name="cs-CZ-Wavenet-A",
    ssml_gender=texttospeech.enums.SsmlVoiceGender.FEMALE)

# Select the type of audio file you want returned
audio_config = texttospeech.types.AudioConfig(
    audio_encoding=texttospeech.enums.AudioEncoding.MP3,
    pitch=0)

# Perform the text-to-speech request on the text input with the selected
# voice parameters and audio file type
response = client.synthesize_speech(synthesis_input, voice, audio_config)

where the name param can be found in the JSON example over here. For example in Czech it would be cs-CZ-Wavenet-A and "cs-CZ-Standard-A".

Upvotes: 3

Related Questions