Using Google ASR

· Uncategorized
Authors

Update: Now Google ASR needs a key!

Steps for generating Google Speech API key (Thanks to my colleague Chirag Patel)

Assumed that you have a Google account (if you have a Gmail account – you can safely assume that you have a Google account! else create one.)

Make sure you are a member of chromium-dev-discussion list by joining the Google group https://groups.google.com/a/chromium.org/forum/?fromgroups#!forum/chromium-dev  using your Google credentials. (This is required to generate the Speech API key!)
Go to Google developer console https://console.developers.google.com/ (logged in with your credentials)

  • Create a Project (say “myfirstspeechasr“) and click on the project
  • Click on the “Manage and Enable API” button
  • Search for word “speech” (in the search box!)
  •  Click on “Speech API”  and then click  “Enable API
  •  Then click on “Credentials” to generate the API Key.
  • You will see a message  “Here is your API key: AIXXXyXXXvdk3TbXXXX7MsXXXUBv-LYjXXXXrOk”
  • The string AIXXXyXXXvdk3TbXXXX7MsXXXUBv-LYjXXXXrOk is the key (Note: this is a fictitious key but the format should be more or less like this)

Now, replace the wget (line 6 in the old post as)

wget -q -U “Mozilla/5.0″ –no-proxy –post-file $1.flac –header=”Content-Type: audio/x-flac; rate=16000” -O – “http://www.google.com/speech-api/v1/recognize?lang=${LANGUAGE}&key=”AIXXXyXXXvdk3TbXXXX7MsXXXUBv-LYjXXXXrOk”&client=chromium” > $1.ret

Namely,

1 #!/bin/sh
2 LANGUAGE=”en-in”
3 echo “1 SoX Sound Exchange – Convert $1.wav to $1.flacC with 16000”
4 sox $1.wav $1.flac rate 16k
5 echo “2 Submit to Google Voice Recognition $1.flac”
6 wget -q -U “Mozilla/5.0″ –no-proxy –post-file $1.flac –header=”Content-Type: audio/x-flac; rate=16000” -O – “http://www.google.com/speech-api/v1/recognize?lang=${LANGUAGE}&key=”AIXXXyXXXvdk3TbXXXX7MsXXXUBv-LYjXXXXrOk&client=chromium” > $1.ret
7 echo “3 SED Extract recognized text”
8 cat $1.ret | sed ‘s/.*utterance”:”//’ | sed ‘s/”,”confidence.*//’ > $1.txt
9 echo “4 Remove Temporary Files”
10 rm $1.flac
11 rm $1.ret
12 echo “5 Show Text ”
13 cat $1.txt

Hope this helps.

I realized (after updating this post!) that there is a nice(r) post at https://aminesehili.wordpress.com/2015/02/08/on-the-use-of-googles-speech-recognition-api-version-2/ may be you should look this up 🙂

==Does not Work: No Key Based use of Google Speech API===

This is the shell script that uses Google ASR to recognize a speech utterance in Indian English (see YourTube Demo).

1 #!/bin/sh
2 LANGUAGE=”en-in”
3 echo “1 SoX Sound Exchange – Convert $1.wav to $1.flacC with 16000”
4 sox $1.wav $1.flac rate 16k
5 echo “2 Submit to Google Voice Recognition $1.flac”
6 wget -q -U “Mozilla/5.0″ –no-proxy –post-file $1.flac –header=”Content-Type: audio/x-flac; rate=16000” -O – “http://www.google.com/speech-api/v1/recognize?lang=${LANGUAGE}&client=chromium” > $1.ret
7 echo “3 SED Extract recognized text”
8 cat $1.ret | sed ‘s/.*utterance”:”//’ | sed ‘s/”,”confidence.*//’ > $1.txt
9 #echo “4 Remove Temporary Files”
10 #rm $1.flac
11 #rm $1.ret
12 echo “5 Show Text ”
13 cat $1.txt

9 Comments

Comments RSS
  1. wowzers

    Hi, is this still current? Also, is -O correct or should it be -D ?

  2. omargalav

    i try to send sound flac but look ii that the response.

    –2014-09-03 15:42:56– (intento: 3) http://www.google.com/speech-api/v1/recognize?lang=es_ES
    Connecting to http://www.google.com|74.125.229.208|:80… conectado.
    Reintentando.

    –2014-09-03 15:43:01– (intento: 4) http://www.google.com/speech-api/v1/recognize?lang=es_ES
    Connecting to http://www.google.com|74.125.229.208|:80… conectado.
    Reintentando.

    –2014-09-03 15:43:07– (intento: 5) http://www.google.com/speech-api/v1/recognize?lang=es_ES
    Connecting to http://www.google.com|74.125.229.208|:80… conectado.
    Reintentando.

    • sunilkumarkopparapu

      There is a need for a “key” from Google. Look up the web for more details. I will try and update as soon as I can.

      • Junjie

        Hi,

        I try your above sheet by typing “./google_asr.sh speech” in the terminal. However, I don’t know why it is stuck at Step 2 for a long time when submitting the flac file to google Voice Recognition. After a while, the sheet passes through Step 5, but no word shows and the generated txt is blank. I have checked that the generated speech.flac file is fine.

        Is there any extra configuration on the network? Can you explain more details on the “key” from Google? Thanks!

  3. Junjie

    Hi,

    I try your above sheet by typing “./google_asr.sh speech” in the terminal. However, I don’t know why it is stuck at Step 2 for a long time when submitting the flac file to google Voice Recognition. After a while, the sheet passes through Step 5, but no word shows and the generated txt is blank. I have checked that the generated speech.flac file is fine.

    Is there any extra configuration on the network? Thanks!

    $ ./google_asr.sh speech
    1 SoX Sound Exchange — Convert speech.wav to speech.flacC with 16000
    2 Submit to Google Voice Recognition speech.flac
    3 SED Extract recognized text
    4 Remove Temporary Files
    5 Show Text

  4. Sunil Kopparapu

    @Junjie Will put a short note on how to generate the key. Been a while since I promised. But will put it up soon 😉

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: