如何用Python调用Google TTS Wavenet语音



我正在使用Google的TTS库。我的Python中的代码几乎与他们的示例代码相同。但是我无法通过启用Wavenet语音来调用他们的服务(我的目标是非英语语言,但也显示为支持WaveNet语音(。我的假设是它将基于此参数。但是我在任何地方都看不到它的用途。

弄清楚:

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

名称param 可以在此处的JSON示例中找到。例如,在捷克语中,它将是 cs-cz-Wavenet-a >" CS-Cz-standard-a"

最新更新