簡體   English   中英

錯誤:無法在Google雲語音中完成“ storage_client = storage.Client()”

[英]Bad:Can't finish “storage_client = storage.Client()” in google cloud speech

感謝您的幫助!當我在Jupyter筆記本中使用Google Cloud Speech時,運行以下代碼時發生了錯誤:

import os
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] =  os.path.join(os.path.realpath('.'),'Lu/Lu-xxxxxxxxxx.json')

os.path.join(os.path.realpath('.'),'Lu/Lu-xxxxxxxxxx.json')

with open("Lu/Lu-xxxxxxxxxx.json") as f:
    GOOGLE_CLOUD_SPEECH_CREDENTIALS = f.read()

def transcribe_gcs(gcs_uri):
    from google.cloud import speech
    ...
    client = speech.SpeechClient()
    audio = ...
    config = ...
    operation = client.long_running_recognize(config, audio)

    ...
    response = operation.result(timeout=90)
    ...

# Imports the Google Cloud Storage client library
from google.cloud import storage
# Instantiates a client()
storage_client = storage.Client()

讀取最后一行時,它說DefaultCredentialsError:File /home/luffy/Lu/Lu-xxxxxxxxxx.json was not found.

但是我確定.json在那里。 我的項目身份驗證配置是否存在一些問題?

當我看這些問題時,我感到我缺乏一些基礎知識。 我不完全了解Google Cloud Speech和python等之間的關系。在哪里可以學習?

謝謝!

事實證明,這可能是配置問題。 我對Google Cloud的所有“設置環境”過程都做得不好。 對於ubuntu和Debian的這部分快速入門 ,我將項目更改為我現在正在使用的項目(前一段時間,我在google cloud上更改了我的項目,但沒有跟隨該網站更改我的項目)。 我為本地項目文件夾設置了“ virtualenv”環境。 經過這些步驟,我成功了!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM