tutorial to use google speech API
I spent a long time searching for a good framework or API to do my oral programming work, yesterday I finally find a good way to do that.
First you need to use google speech api, and even before using this, you need to activate speech API privilege and generate a APIkey for youself.
I disclaim here first that google speech API is not
an public and official API so it is not
recommended to use it in product environment. Also, I encourage everyone to obtain your own APIkey in case of harassing other developers’ usage quota(who knows when will google starts to restrain it?).
create api key
For those who want to apply a api-key, please follow this page:
Following is my personal experience on 2014/05/16. Notice this instruction and google console might change by time, so always keep updated.
- Join chromium google user group, otherwise you can not see the special API in google console.
- Go to google-console.
- use a project or create one if you don’t have one.
- Click on
APIs & auth -> APIs
, search forspeech
and enable this API(make sure you finished step 1 otherwise you are unable to see this entry). - Click
APIs & auth -> Credential
, on the right panel you can see there will have a button namedcreate new key
, click it. - Create a
browser key
. The referrers option is up to you.
quick test API
- You can download sample audio file from here for your convenience.
- use
API key
to call google speech API use curl if you are using linux, this will save you a lot of time to see a quick result:After a second two json data will return:1
curl -X POST --data-binary @./good-morning-google.flac --header 'Content-Type: audio/x-flac; rate=44100;' 'https://www.google.com/speech-api/v2/recognize?output=json&lang=en-us&key=yourkey'
1 |
|
A little bit of weird because there are 2 json with the first one is empty.