Hi I'm using a json file to authenticate my access to google speech API. My code worked for a few attempts of sending a 10s wav file but now it gives this error:
Traceback (most recent call last):
File "/home/ishan/Google_Cloudspeech_on_pepper/cloudspeechtest.py", line 37, in <module>
response = client.recognize(config, audio)
File "/usr/local/lib/python2.7/dist-packages/google/cloud/gapic/speech/v1/speech_client.py", line 201, in recognize
return self._recognize(request, options)
File "/usr/local/lib/python2.7/dist-packages/google/gax/api_callable.py", line 452, in inner
return api_caller(api_call, this_settings, request)
File "/usr/local/lib/python2.7/dist-packages/google/gax/api_callable.py", line 438, in base_caller
return api_call(*args)
File "/usr/local/lib/python2.7/dist-packages/google/gax/api_callable.py", line 376, in inner
return a_func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/google/gax/retry.py", line 127, in inner
' classified as transient', exception)
google.gax.errors.RetryError: RetryError(Exception occurred in retry method that was not classified as transient, caused by <_Rendezvous of RPC that terminated with (StatusCode.RESOURCE_EXHAUSTED, Quota exceeded.)>)
Here is my code: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import io
from os import path
import time
# Imports the Google Cloud client library
from google.cloud import speech
# from google.cloud import datastore #dont need this
from google.cloud.speech import enums
from google.cloud.speech import types
#client = datastore.Client()
GOOGLE_APPLICATION_CREDENTIALS = path.join(
path.dirname(__file__),
'ishan_sr.json')
# Instantiates a client
client = speech.SpeechClient()
# The name of the audio file to transcribe
file_name = path.join(
path.dirname(__file__),
'Fish.wav')
# Loads the audio into memory
with io.open(file_name, 'rb') as audio_file:
content = audio_file.read()
audio = types.RecognitionAudio(content=content)
config = types.RecognitionConfig(
encoding=enums.RecognitionConfig.AudioEncoding.LINEAR16,
sample_rate_hertz=44100,
language_code='en-US')
# Detects speech in the audio file
t1 = time.time()
response = client.recognize(config, audio)
t2 = time.time()
t3 = t2-t1
print 'Google cloud response time = %s' %(t3)
for result in response.results:
print('Transcript: {}'.format(result.alternatives[0].transcript))
my project shows I have not used up any of the quota at all. Other people have this problem but no response. Any help is appreciated.