Search code examples
google-cloud-platformgoogle-cloud-speech

Where to find stored results from a Cloud Speech-to-Text API call?


I am performing a batch of asynchronous long_running_recognize transcriptions using Google's Cloud Speech-to-Text, and it appears that some of my requests are timing out, and/or not returning anything. How may I access the stored results of my API calls? I'm using Python 3.7.

I realize that the API call returns results to the function that made the call. What I'm asking is, does Google store the results of my API calls somewhere? And how do I access them?


Solution

  • You should probably call the asynchronous method when submitting larger audio files. Specifically this calls the LongRunningRecognize method. This should submit a Long Running Operation and should return an immediate response, for example:

    {
      "name": "operation_name",
      "metadata": {
        "@type": "type.googleapis.com/google.cloud.speech.v1.LongRunningRecognizeMetadata"
        "progressPercent": 34,
        "startTime": "2016-08-30T23:26:29.579144Z",
        "lastUpdateTime": "2016-08-30T23:26:29.826903Z"
      }
    }
    

    With this response you can poll for the result given the operation_name:

    curl -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
         -H "Content-Type: application/json; charset=utf-8" \
         "https://speech.googleapis.com/v1/operations/your-operation-name"
    

    Note: when you are not receiving any return values using this method, I would suggest increasing the timeout and retry of the client. This can be done with something like:

    long_running_recognize(retry=10, timeout=300)
    

    Source