Asterisk integration with Sphinx Voice recognition system

 

I was looking for the information about the integration of Sphinx 4 with asterisk for a while, but due to various reasons, I haven't had success to configure asterisk with Sphinx. I tried a lot to integrate Asterisk with Sphinx voice recognition system but really I had a very hard time to configure sphinx2 in an appropriate way. There are lots of Sphinx versions, but as for my experience the newer versions of Sphinx (sphinx3 & sphinx4) will not work with Asterisk due to high Sphinx audio conversion module frequency.

Below are the instructions on getting sphinx installed and running, it should work on any Linux distribution.

Download sphinx2 version 0.6 from

http://sourceforge.net/project/showfiles.php?group_id=1904

Untar it

# tar zxvf sphinx2-0.6.tar.gz

# cd sphinx2-0.6

# ./configure –prefix=/usr/local/sphinx

# make

# make install

This will install sphinx into /usr/local/sphinx

Now install the perl modules for Sphinx

Download Speech-Recognizer-SPX from

http://search.cpan.org/CPAN/authors/id/D/DJ/DJHD/Speech-Recognizer-SPX-0.0801.tar.gz

# tar zxvf Speech-Recognizer-SPX-0.0801.tar.gz

# cd Speech-Recognizer-SPX-0.0801

# perl Makefile.PL –sphinx-prefix=/usr/local/sphinx

# make

# make install UNINSTALL=1

This should install the perl module. (You can also use "cpan" command to

install, and search for perl modules)

We will now install a simple dictionary with (YES, NO, ACCEPT, and

CANCEL)

Get the dictionary from

http://turnkey-solution.com/confirm.tgz

Install it

# cd /usr/local/sphinx/share/sphinx2/model/lm/

# tar zxvf /usr/src/confirm.tgz

Now we need to replace the acoustic model.

Download

http://www.speech.cs.cmu.edu/sphinx/models/hmm/communicator-2000-11-17-2.tgz

# cd /tmp

# tar zxvf /usr/src/communicator-2000-11-17-2.tgz

# cd communicator-2000-11-17-2/

# mv sphinx_2_format /usr/local/sphinx/share/sphinx2/model/hmm/communicator

Thats done

Download Agi, client and Sphinx server file:

# wget http://www.syednetworks.com/asterisk-sphinx.rar

Now use the downloaded files and save sc_client and sr_server

in /usr/local/bin and the agi file into /var/lib/asterisk/agi

Make sure turn them into executables by using "chmod +x filename"

command.

You will also need to install perl module Asterisk::AGI download and

install it with cpan or as done above.

Now start the sphinx server in one terminal

#/usr/local/bin/sr_server &

Now for testing you should record small phrases in "YES", "NO", "ACCEP",

CANCEL, in small wave files (make sure use 8k bit rate, mono and 16

bits). You can use audacity for that.

Test the client

$ /usr/local/bin/sr_client accept.wav

Result: ACCEPT

$ /usr/local/bin/sr_client no.wav

Result: NO

$ /usr/local/bin/sr_client yes.wav

Result: YES

Now make an extension

exten => 300,1,AGI(sphinx_test.agi); exten => 300,2,Hangup

Look at the asterisk console output while calling the extension, it will complain about some IVR files, make sure you put them in place. ANd then speak the simple phrases like above.

Like this post? Share it:
  • Facebook
  • Digg
  • Twitter
  • del.icio.us
  • StumbleUpon
  • PDF
  • Mixx
  • RSS
Tags: , , , , , , ,

Related posts