Thank you for helping me! When I use google cloud speech in Jupyter notebook, the error happened when I ran the following codes:
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()
When reading the last line, it said DefaultCredentialsError:File /home/luffy/Lu/Lu-xxxxxxxxxx.json was not found.
But I'm sure the .json is there. Is there some problems with my project authentication configuration?
When I look at these problems, I feel that I lack some bacic knowledge. I don't fully understand the relation between google cloud speech and python, etc. Where can learn them?
Thank you!
It turns out that It may be a configureation problem. I didn't finish well all the 'setting up environment' process for google cloud. Fot this part quickstart for ubuntu and Debian, I changed the project to the project I'm working right now(I changed the my project on google cloud some time before, but didn't follow this website to change my project). The I set up 'virtualenv' environment for my local project folder. After these steps, I succeeded!