Reputation: 1
I receive the following error when I try to run the sample code for Google's Speech To Text API.
Code:
from google.cloud import speech_v1p1beta1
from google.cloud.speech_v1p1beta1 import enums
def sample_recognize(storage_uri):
"""
Performs synchronous speech recognition on an audio file
Args:
storage_uri URI for audio file in Cloud Storage, e.g. gs://[BUCKET]/[FILE]
"""
client = speech_v1p1beta1.SpeechClient()
# storage_uri = 'gs://cloud-samples-data/speech/brooklyn_bridge.mp3'
# The language of the supplied audio
language_code = "en-US"
# Sample rate in Hertz of the audio data sent
sample_rate_hertz = 44100
# Encoding of audio data sent. This sample sets this explicitly.
# This field is optional for FLAC and WAV audio formats.
encoding = enums.RecognitionConfig.AudioEncoding.MP3
config = {
"language_code": language_code,
"sample_rate_hertz": sample_rate_hertz,
"encoding": encoding,
}
audio = {"uri": storage_uri}
response = client.recognize(config, audio)
for result in response.results:
# First alternative is the most probable result
alternative = result.alternatives[0]
print(u"Transcript: {}".format(alternative.transcript))
sample_recognize("gs://news2ttestbucket/untitled.mp4")
Error:
google.api_core.exceptions.PermissionDenied: 403 starting-account-950772mckg4@news2ttest-1581392888505.iam.gserviceaccount.com does not have storage.objects.get access to news2ttestbucket/untitled.mp4.
With regards to the bucket, I've given every conceivable permission to every level of the project and it still refuses to access the file.
Really don't get why it's failing and would appreciate any assistance, thanks!!
Upvotes: 0
Views: 494
Reputation: 15266
In your image, you have shown that you have permissions for:
If we look in detail at your error message:
google.api_core.exceptions.PermissionDenied:
403 starting-account-950772mckg4@news2ttest-1581392888505.iam.gserviceaccount.com
does not have storage.objects.get access to news2ttestbucket/untitled.mp4.
We see that the identity that is requesting access to work with the bucket is called:
starting-account-950772mckg4@news2ttest-1581392888505.iam.gserviceaccount.com
Assuming that identity is neither a project Editor, Owner or Viewer then none of the permissions apply. Create a new entry by clicking "Add members" and add permissions for that identity explicitly.
Upvotes: 2