Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google speech api Empty Results JSON

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

like image 993
Shabna Subin Avatar asked Aug 15 '26 17:08

Shabna Subin


1 Answers

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.

like image 168
blambert Avatar answered Aug 19 '26 09:08

blambert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!