0

this is my first post on StackOverflow. I get ResourceExhausted with Google Speech API - LongRunningRecognizeResponse. It says "e.g. check quota", but I'm not sure what it means exactly. How do I check quota and make necessary setups?

func sendRequestWithUri(uri string)
 (*speechpb.LongRunningRecognizeResponse, error) {
    log.Printf("Uri: %s", uri)

    ctx := context.Background()
    client, err := speech.NewClient(ctx)
    if err != nil {
        log.Fatalf("Failed to create client: %v", err)
    }

    // Create Request with config
    req := &speechpb.LongRunningRecognizeRequest{
        Config: &speechpb.RecognitionConfig{
            Encoding:        speechpb.RecognitionConfig_FLAC,
            SampleRateHertz: 44100,
            LanguageCode:    "en-US",
        },
        Audio: &speechpb.RecognitionAudio{
            AudioSource: &speechpb.RecognitionAudio_Uri{
                Uri: uri,
            },
        },
    }

    log.Printf("Created request: %s", req)

    op, err := client.LongRunningRecognize(ctx, req)
    if err != nil {
        return nil, err
    }
    return op.Wait(ctx)
}

The code takes the URL for a FLAC file uploaded on Google Cloud Storage. After attempts to try with files in different lengths, I always receive:

rpc error: code = ResourceExhausted desc = Resource has been exhausted (e.g. check quota). exit status 1

Then I opened GCP console, and simply enabled Speech API on one of the projects, where I want to work with Speech API. On a local machine (macOS, bash), I have selected the target project via gcloud gcloud config configurations create myproject and gcloud auth login. It looks like project config is successfully created:

$ gcloud config list
[core]
account = mygmail
disable_usage_reporting = False
project = myproject
Your active configuration is: [myproject]

After enable and setup, I still get the same ResourceExhausted. Do I miss anything? Thanks.

kostix
  • 51,517
  • 14
  • 93
  • 176
tanquar
  • 1
  • 1
  • 1
  • Quotas are listed here: https://cloud.google.com/speech/quotas. Most likely you exceeded one of them. – Nikolay Shmyrev Jan 11 '18 at 23:29
  • 1
    Thanks! I checked the list of quota. I guess I use Asynchronous for LongRunningRecognizeRequest. If that's the case the length should be less than 180 min. I was testing with 55 sec FLAC but I still received the above quota error. Request Limit should be no problem, since I was testing alone, with several short test FLAC files that are 30 sec to 3 min, manually one by one not concurrently. – tanquar Jan 12 '18 at 15:25

0 Answers0