0

I want to use Google SpeechRecognition service as a fallback for SpeechRecognition API, the thing is that in the docs I only see a way to authenticate using the API key.

https://cloud.google.com/speech-to-text/docs/reference/rest/v1/speech/recognize

It seems to me like not a secure way and is easily abused, can I authenticate using a generated temp Bearer key?

1 Answer 1

1

You can use the following code sample to send a recognize REST request to the Speech-to-Text API.

Input json:

{
  "config": {
      "encoding":"FLAC",
      "sampleRateHertz": 16000,
      "languageCode": "en-US",
      "enableWordTimeOffsets": false
  },
  "audio": {
      "uri":"gs://cloud-samples-tests/speech/brooklyn.flac"
  }
}

Curl command:

curl -s -H "Content-Type: application/json" \
    -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
    https://speech.googleapis.com/v1/speech:recognize \
    -d @Input.json

Output:

enter image description here

For more information you can refer to this document.

Sign up to request clarification or add additional context in comments.

1 Comment

Hey, thanks for the comment! I use serverless lambda so Id rather not use gcloud, but in worse case scenario is this key secure to be used in webapp client side?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.