I made an API call normally with properly formatted JSON Request with mp3 file, and I am expecting the result JSON data to include "results" object with "alternatives" object with "transcript" and "confidence" values.
Instead what I get as a result is "{}" (an empty JSON object).
Operating system using is ubuntu15.04.
The JSON request file with the following text is created, and save it as a sync-request.json plain text file:
{
"config": {
"encoding": "LINEAR16",
"sampleRate": 16000,
"languageCode": "en-US"
},
"audio": {
"uri": "gs://audiobucketceino/Learn English - Lesson 41- Hi How are you - Pronunciation-[AudioTrimmer.com].mp3"
}
}
curl used to make a speech:syncrecognize request is :
curl -s -k -H "Content-Type: application/json" -H "Authorization: Bearer [access-token]" https://speech.googleapis.com/v1beta1/speech:syncrecognize -d @sync-request.json
Test file is attached in :
https://drive.google.com/file/d/0B7cqXnHXm78bLWdyYWhpVEdkT0U/view?usp=sharing
The google speech API doesn't support mp3 files directly. It only supports the five listed in the documentation. The easiest thing would be to convert the mp3 file to a wav file using sox or a similar tool (sudo apt-get install sox
):
sox lesson41.mp3 lesson41.wav
The wav file should be compatible with the LINEAR16
encoding you supplied. You'll want to make sure make sure the sample rate is 16k and the samples are 16 bit. To be safe try this:
sox lesson41.mp3 -r 16000 -c 1 -b 16 lesson41.wav
If you have any trouble getting sox
there are lots of other tools that should be able to do the conversion too.