Google cloud texttospeech“没有属性'SynthesisInput'”错误

2024-09-30 23:47:26 发布

您现在位置:Python中文网/ 问答频道 /正文

https://cloud.google.com/text-to-speech/docs/libraries?hl=pt-br#client-libraries-install-python

在尝试Google的主要示例时,我遇到了以下错误:

AttributeError                            Traceback (most recent call last)
<ipython-input-92-866a7868dbb4> in <module>
     10 
     11 # Set the text input to be synthesized
---> 12 synthesis_input = texttospeech.SynthesisInput(text="Hello, World!")
     13 
     14 # Build the voice request, select the language code ("en-US") and the ssml

AttributeError: module 'google.cloud.texttospeech' has no attribute 'SynthesisInput'

有什么建议吗? 使用conda forge:google cloud texttospeech 1.0.1


Tags: thetotexthttpscomclouddocslibraries
1条回答
网友
1楼 · 发布于 2024-09-30 23:47:26

我使用相同的库(googlecloudtexttospeech==1.0.1)尝试了您的示例,但也失败了。解决方法是只需使用!pip install upgrade google-cloud-texttospeech 将库更新到最新版本(2.3.0),代码片段就可以了

使用过时的1.0.1版本时出错

enter image description here

出于测试目的,我包括打印编码响应。 enter image description here

相关问题 更多 >