Python 找不到google云合成语音501方法

Python 找不到google云合成语音501方法,python,google-api,google-cloud-platform,gcloud,google-text-to-speech,Python,Google Api,Google Cloud Platform,Gcloud,Google Text To Speech,严格使用提供的代码作为示例来运行google cloud文本到语音api: def synthesize_text(text): """Synthesizes speech from the input string of text.""" from google.cloud import texttospeech client = texttospeech.TextToSpeechClient() input_text = texttospeech.types

严格使用提供的代码作为示例来运行google cloud文本到语音api:

def synthesize_text(text):
    """Synthesizes speech from the input string of text."""
    from google.cloud import texttospeech
    client = texttospeech.TextToSpeechClient()

    input_text = texttospeech.types.SynthesisInput(text=text)

    # 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-US',
        ssml_gender=texttospeech.enums.SsmlVoiceGender.FEMALE)

    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"')
我收到了上面的错误消息:mesage
google.api\u core.exceptions.MethodNotImplemented 501 Method not found

这似乎是谷歌内部的错误。我已经仔细检查了我的证件。 错误来自此特定的
行:response=client.synthesis\u speech(输入\u文本、语音、音频\u配置)


请提供帮助。

此时,由于某种原因,python客户端库已经关闭。但是,通过检查,我们可以看到唯一可用的端点是v1beta1

如果您遵循并使用google.cloud import texttospeech_v1中的
,您的客户端将尝试使用
https://texttospeech.googleapis.com/v1/
而不是
https://texttospeech.googleapis.com/v1beta1/
。这个错误不是4XX而是5XX,这一事实让我认为可能端点本身存在,但它们尚未实现,或者您不允许发现它们(因此它们看起来没有实现)


尝试将您的导入更改为(
来自google.cloud import texttospeech_v1beta1
)中的导入,并查看这是否有任何区别。

是否使用或?在api仪表板中,请求来自“texttospeech.v1”