'en-GB-Wavenet-C' 不起作用 [Google Cloud Text to Speech]

'en-GB-Wavenet-C' doesn't work [Google Cloud Text to Speech]

我是编码初学者。 我在我正在使用的小程序上使用 Google Cloud Text to Speech API for Python。功能正常,我得到了合成语音结果,但是MP3文件和我需要的不一样。我选择'en-GB-Wavenet-C'(英国口音女声)作为language_code,但MP3文件听起来是美国口音男声。

我访问了 Cloud Text to Speech API 网站 (https://cloud.google.com/text-to-speech/) 并尝试了 "Speak it" 演示。我试了一下 'en-GB-Wavenet-C' 听起来是英国口音的女声。

我想知道合适的代码,以便我得到 'en-GB-Wavenet-C' 语音结果。

我将 Windows 子系统中的 Debian 9.3 用于 Linux。

我使用Google Cloud SDK 210.0.0.

提前谢谢你。

真诚的, 和都

这是我的代码:

#!/usr/bin/env python

from google.cloud import texttospeech
client = texttospeech.TextToSpeechClient()

with open('resources/hello.ssml', 'r') as f:
    ssml = f.read()
    input_text = texttospeech.types.SynthesisInput(ssml=ssml)

# Note: the voice can also be specified by name.
# Names of voices can be retrieved with client.list_voices().
voice = texttospeech.types.VoiceSelectionParams(language_code='en-GB-Wavenet-C')

audio_config = texttospeech.types.AudioConfig(
    audio_encoding=texttospeech.enums.AudioEncoding.MP3)

response = client.synthesize_speech(input_text, voice, audio_config)

# The response's audio_content is binary.
with open('output.mp3', 'wb') as out:
    out.write(response.audio_content)
    print('Audio content written to file "output.mp3"')
# [END tts_synthesize_ssml_file]
 voice = texttospeech.types.VoiceSelectionParams(language_code='en-GB-Wavenet-C')

应该是

 voice = texttospeech.types.VoiceSelectionParams(language_code='en-GB', name="en-GB-Wavenet-C")