Speech Recognition

The highest quality free option right now is the Google Speech API.  Internet citizen Lefteris Zafiris has put together a great AGI wrapper that acts as a bridge between Google and Asterisk.  Unfortunately, Google has locked down the API and limited it to 50 queries a day.  In order to use the AGI script, you’ll need a Google API Key with the Speech API enabled.  Here’s how to obtain the key for speech recognition:

  • Join the chromium mailing list. You’ll probably want to choose “don’t send email updates”.
  • Make sure you are logged in with the Google account associated with the email address that you used to subscribe to chromium-dev.
  • Go to https://cloud.google.com/console.  Click the blue Create Project button. Choose whatever you want for a project name. The project ID they assign is fine.
  • In the ‘APIs & auth’ > APIs tab, do a search for “Speech API”. Change status from OFF to ON. If it doesn’t show up in the list then you didn’t properly register for the Chromium mailing list.
  • In the ‘APIs & auth’ > Credentials tab, Click “create new key” under Public API Access. In the “create a new key” pop-up, choose “browser key”. Leave the next textbox blank and hit “create”.
  • Your new API key should now be copied into line 70 of “speech-recog.agi” so that it looks similar to this:
    # Speech API key #
    my $key = “AIzSyDHqVEG0LOu8P7_BWzhgTz-tEggdhzFA”;
  • You only get 50 queries a day, so make them count!

Setting up the Speech Recognition AGI script:

apt-get -y install flac
apt-get -y install libwww-perl
apt-get -y install libjson-perl
wget https://github.com/zaf/asterisk-speech-recog/tarball/master
tar xzf master
cd zaf-asterisk-speech-recog-28405f7/
cp speech-recog.agi /var/lib/asterisk/agi-bin/
;;Simple speech recognition
exten => s,1,agi(speech-recog.agi,en-US)
exten => s,n,Verbose(1,The text you just said is: ${utterance})
exten => s,n,Verbose(1,The probability to be right is: ${confidence})
exten => s,n,Hangup()