【发布时间】:2018-06-19 15:49:01
【问题描述】:
严格使用作为示例提供的代码来运行谷歌云文本到语音 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"')
我收到了上述错误消息google.api_core.exceptions.MethodNotImplemented 501 Method not found。
这似乎是 Google 内部错误。我已经仔细检查了我的凭据。
错误来自这个特定的line: response = client.synthesize_speech(input_text, voice, audio_config)
请帮忙。
【问题讨论】:
标签: python google-api google-cloud-platform gcloud google-text-to-speech