google云合成语音501方法未找到
google cloud synthetizes speech 501 Method not found
严格使用示例代码 运行 google 云文本转语音 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 客户端库有 code for v1 and v1beta1 API versions. However, checking the dicovery service for Google APIs,我们可以看到唯一可用的端点是 v1beta1。
如果您遵循 this library docs 并使用 from google.cloud import texttospeech_v1
,您的客户将尝试使用 https://texttospeech.googleapis.com/v1/
而不是 https://texttospeech.googleapis.com/v1beta1/
。错误不是 4XX 而是 5XX 的事实让我认为端点本身可能存在,但尚未实现,或者您不允许发现它们(因此它们看起来未实现)。
尝试更改 v1beta1 doc (from google.cloud import texttospeech_v1beta1
) 中的导入,看看是否有任何不同。
严格使用示例代码 运行 google 云文本转语音 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 客户端库有 code for v1 and v1beta1 API versions. However, checking the dicovery service for Google APIs,我们可以看到唯一可用的端点是 v1beta1。
如果您遵循 this library docs 并使用 from google.cloud import texttospeech_v1
,您的客户将尝试使用 https://texttospeech.googleapis.com/v1/
而不是 https://texttospeech.googleapis.com/v1beta1/
。错误不是 4XX 而是 5XX 的事实让我认为端点本身可能存在,但尚未实现,或者您不允许发现它们(因此它们看起来未实现)。
尝试更改 v1beta1 doc (from google.cloud import texttospeech_v1beta1
) 中的导入,看看是否有任何不同。