I'm playing with Google Speech Recognition API

After a successfully Getting started I'm trying to understand and made some changes in this first example but I don't know what "gs" protocol is and how to set it to use my own audio file.

sync-request.json

{
  "config": {
      "encoding":"FLAC",
      "sample_rate": 16000
  },
  "audio": {
      "uri":"gs://cloud-samples-tests/speech/brooklyn.flac"
  }
}

I tried to change gs protocol to http protocol but doesn't work.

Thanks in advance.


You can access the file that you mention as follows:

https://storage.googleapis.com/cloud-samples-tests/speech/brooklyn.flac

So, if you create/upload your own file in Google Storage -- like I'm doing now while testing the same API you are using-- the "equivalence" is the following:

https://storage.googleapis.com/ 

translates to

gs://

and viceversa.

I have no idea why Google doesn't explain this clearly.

I hope this helps.


gs:// scheme is used for identifying resources stored in Google Cloud Storage.


This is what Google's API docs says:

https://cloud.google.com/speech/reference/rpc/google.cloud.speech.v1beta1#audioencoding

URI that points to a file that contains audio data bytes as specified in RecognitionConfig. Currently, only Google Cloud Storage URIs are supported, which must be specified in the following format: gs://bucket_name/object_name (other URI formats return google.rpc.Code.INVALID_ARGUMENT).