[英]Attribute Error when importing SpeechClient from google.cloud.speech
I am trying to use Google cloud platform to transcript audio to text.我正在尝试使用谷歌云平台将音频转录为文本。 I am stuck really at the beginning.
我一开始就被卡住了。
When I try to import:当我尝试导入时:
import os
from google.cloud import speech
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = 'speech-333807-fbe7e537e3a2.json'
speech_client = speech.SpeechClient()
The error pops out:错误弹出:
AttributeError: module 'google.cloud.speech' has no attribute 'SpeechClient'
When I try to import this inside python shell, the above error pops out right away after import: from google.cloud import speech.当我尝试在 python shell 中导入此内容时,导入后立即弹出上述错误:from google.cloud import speech。 But strangely enough, when I import it second time, import goes ok.
但奇怪的是,当我第二次导入时,导入正常。
Do you have any clue why this is not working?你知道为什么这不起作用吗?
Thanks a lot!非常感谢!
I just managed to make the audio-to-text speech API work for me.我只是设法使音频到文本的语音 API 为我工作。 You should try this instead:
你应该试试这个:
from google.cloud import speech_v1 as speech
It's maybe just a version issue.可能只是版本问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.