简体   繁体   中英

Google cloud texttospeech "has no attribute 'SynthesisInput'" error

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

While trying the main Google example, I got this error:

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'

Any sugestions? Using conda-forge: google-cloud-texttospeech 1.0.1

I tried your example using the same library (google-cloud-texttospeech==1.0.1) and it also fails. The fix for this is to just simply update your library to the latest version (2.3.0) using !pip install --upgrade google-cloud-texttospeech and your code snippet will work.

Error when using the outdated 1.0.1 version.

在此处输入图像描述

For testing purposes I included printing of the encoded response. 在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM