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
# tar zxvf sphinx2-0.6.tar.gz
# cd sphinx2-0.6
# ./configure –prefix=/usr/local/sphinx
# make install
This will install sphinx into /usr/local/sphinx
Now install the perl modules for Sphinx
Download Speech-Recognizer-SPX from
# tar zxvf Speech-Recognizer-SPX-0.0801.tar.gz
# cd Speech-Recognizer-SPX-0.0801
# perl Makefile.PL –sphinx-prefix=/usr/local/sphinx
# 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
Get the dictionary from
# cd /usr/local/sphinx/share/sphinx2/model/lm/
# tar zxvf /usr/src/confirm.tgz
Now we need to replace the acoustic model.
# 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
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"
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
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
$ /usr/local/bin/sr_client no.wav
$ /usr/local/bin/sr_client yes.wav
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.