Speech API retry error

120 views
Skip to first unread message

Ishan Sawant

unread,
Jan 11, 2018, 10:40:35 PM1/11/18
to Chromium-dev
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.

PhistucK

unread,
Jan 12, 2018, 2:55:28 AM1/12/18
to ishan.s...@gmail.com, Chromium-dev
(Sorry for the generic response, there have been numerous off topic threads about this already)
Unless you are using the speech API for Chrome development, you are not allowed to use it (see https://www.chromium.org/developers/how-tos/api-keys and many, many past discussions).
Instead, look into the Cloud Speech API.
For discussions regarding the cloud speech API, see https://groups.google.com/forum/#!forum/cloud-speech-discuss or stackoverflow.com with the google-cloud-speech tag.

Do not post about this again in the various Chromium groups. It is completely off topic.




PhistucK

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+unsubscribe@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/91393157-9ec1-495d-ba76-4518ad708f44%40chromium.org.

Reply all
Reply to author
Forward
0 new messages