简体   繁体   English

从 google.cloud.speech 导入 SpeechClient 时出现属性错误

[英]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.

相关问题 来自 google.cloud.speech 导入枚举的错误 google.cloud.speech 导入错误:无法导入名称“枚举” - ERROR google.cloud.speech from google.cloud.speech import enums ImportError: cannot import name 'enums' App Engine错误没有模块google.cloud.speech和appengine.api - App Engine Error No module google.cloud.speech and appengine.api 无法在Google Cloud Speech中完成“ client = speech.SpeechClient()” - Can't finish “client = speech.SpeechClient()” in Google Cloud Speech 从 google.cloud.speech_v1 导入枚举时遇到问题 - trouble importing enums from google.cloud.speech_v1 当'pip install google-cloud-speech'发生错误 - error occurred when 'pip install google-cloud-speech' 导入google-cloud-bigquery python模块时出错 - error when importing google-cloud-bigquery python module Google Cloud语音识别权限被拒绝错误 - Google Cloud Speech Recognition Permission Denied Error 语音请求错误中的Google的Cloud Speech API异常 - Google's Cloud speech API Exception in speech request error 使用Google Speech API在python中出现属性错误 - Attribute error in python with Google Speech API 使用Google Cloud Speech转录音频文件时如何解决“请求包含无效的参数错误” - How to fix “request contains an invalid argument error” when transcribing audio file with Google Cloud Speech
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM