I also have the same problem that the Google Speech API returns an empty result. I used FFmpgeg to convert my audio file to LINEAR16. To install this tool, I used Homebrew:
brew install ffmpeg
To convert my audio file to LINEAR16, I used this command:
ffmpeg -i input.flac -f s16le -acodec pcm_s16le output.raw
And after I uploaded it to my google stogage: https://console.cloud.google.com/storage/browser/
Here is my configuration JSON file for the request:
{ 'config': { 'encoding':'LINEAR16', 'sampleRate': 16000, 'languageCode': 'en-US' }, 'audio': { 'uri':'gs://your-bucket-name/output.raw' } }
For files over 1 minute, you need to use the Asyncrecognize method:
curl -s -k -H "Content-Type: application/json" \ -H "Authorization: Bearer [YOUR-KEY]" \ https://speech.googleapis.com/v1beta1/speech:asyncrecognize \ -d @sync-request.json
it will return the operation identifier. You can check if he is ready to get the result of the operation:
curl -s -k -H "Content-Type: application/json" \ -H "Authorization: Bearer " [YOUR-KEY]\ https://speech.googleapis.com/v1beta1/operations/[OPERATION-ID]
source share