【问题标题】:Attribute Error when importing SpeechClient from google.cloud.speech从 google.cloud.speech 导入 SpeechClient 时出现属性错误
【发布时间】:2022-05-17 03:14:28
【问题描述】:

我正在尝试使用 Google 云平台将音频转录为文本。我真的一开始就卡住了。

当我尝试导入时:

import os
from google.cloud import speech
    
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = 'speech-333807-fbe7e537e3a2.json'
speech_client = speech.SpeechClient()

错误弹出:

AttributeError: module 'google.cloud.speech' has no attribute 'SpeechClient'

当我尝试在 python shell 中导入它时,导入后立即弹出上述错误:from google.cloud import speech。但奇怪的是,当我第二次导入时,导入正常。

你知道为什么这不起作用吗?

非常感谢!

【问题讨论】:

    标签: python google-cloud-platform text-to-speech


    【解决方案1】:

    我刚刚设法让音频到文本语音 API 为我工作。你应该试试这个:

    from google.cloud import speech_v1 as speech
    

    可能只是版本问题。

    【讨论】:

      猜你喜欢
      • 2020-04-05
      • 2020-01-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-29
      相关资源
      最近更新 更多