I'm trying to execute google-speech-to-text from apps script. Unfortunately, I cannot find any examples for apps script or pure HTTP, so I can run it using simple UrlFetchApp.
I created a service account and setup a project with enabled speech-to-text api, and was able to successfully run recognition using command-line example
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 @sync-request.json
which I can easily translate to UrlFetchApp call, but I don't have an idea to generate access token created by
gcloud auth application-default print-access-token
Is there a way to get it from apps script using service account credentials?
Or is there any other way to auth and access speech-to-text from apps script?