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.
Tags: asterisk with Sphinx, Download sphinx2, Speech-Recognizer-SPX, Sphinx, Sphinx 4
Hi,
Thanks for the excellent instruction.
But I got error while I am trying to start the sphnix server:
#./sr_server.dat &
——————————
Can’t load
‘/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/Speech/Recognizer/SPX/SPX.so’
for module Speech::Recognizer::SPX: libsphinx2.so.0:
cannot open shared object file: No such file or
directory at
/usr/lib/perl5/5.8.8/i386-linux-thread-multi/DynaLoader.pm
line 230.
at ./sr_server.dat line 15
Compilation failed in require at ./sr_server.dat line
15.
BEGIN failed–compilation aborted at ./sr_server.dat
line 15.
—————————-
Need Advice,
Many thanks
Kevin
Kavin, what OS you are using for the Sphinx? it looks like you’re trying to install a perl module that provides an interface to a c library, which is not installed.
Please try to install Recognizer again properly.
I have the same problem as kevin using:
[root@bk sphinx2-0.6]# uname -a
Linux bk 2.6.18-1.2849.fc6 #1 SMP Fri Nov 10 12:45:28 EST 2006 i686 i686 i386 GNU/Linux
Using this OS: [root@ktel model]# uname -a
Linux ktel 2.6.18-1.2798.fc6 #1 SMP Mon Oct 16 14:37:32 EDT 2006 i686 i686 i386 GNU/Linux
all the things goes fine and is working
Can someone post the confirm.tgz in an alternate site. The original site http://turnkey-solution.com is down.
Or if someone can email me the dictionary it would be great as well
My id is “bsvinay” at good old “gmail” dot “com”.
Thanks,
Vinay
Never mind, I found out how to create confirm.tgz.
Create a text file containing four lines for Yes, No, Accept and Cancel.
And use this link to create your lm files
http://www.speech.cs.cmu.edu/tools/lmtool.html
Hi there. Thanx for article!
I’m runnig freebsd 6.2
uname -a
FreeBSD usaster.intellecom.ua 6.2-RELEASE FreeBSD 6.2-RELEASE #0: Wed Nov 7 17:16:04 EET 2007 root@usaster.intellecom.int:/usr/obj/usr/src/sys/MYKERN i386
When I try to compile Speech-Recognizer-SPX-0.0801 I got an error:
cp SPX.pm blib/lib/Speech/Recognizer/SPX.pm
cp SPX/Config.pm blib/lib/Speech/Recognizer/SPX/Config.pm
cp SPX/Server.pm blib/lib/Speech/Recognizer/SPX/Server.pm
/usr/bin/perl /usr/local/lib/perl5/5.8.8/ExtUtils/xsubpp -typemap /usr/local/lib/perl5/5.8.8/ExtUtils/typemap -typemap typemap SPX.xs > SPX.xsc && mv SPX.xsc SPX.c
Please specify prototyping behavior for SPX.xs (see perlxs manual)
cc -c -I/usr/local/include -DAPPLLIB_EXP=”/usr/local/lib/perl5/5.8.8/BSDPAN” -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -g -O2 -DVERSION=\”0.0801\” -DXS_VERSION=\”0.0801\” -DPIC -fPIC “-I/usr/local/lib/perl5/5.8.8/mach/CORE” SPX.c
SPX.xs: In function `new_seg_sv’:
SPX.xs:294: error: structure has no member named `fsg_state’
*** Error code 1
Stop in /root/.cpan/build/Speech-Recognizer-SPX-0.0801.
Sphinx2 directory is /usr/local (installed from ports)
perl version 5.8.8_1
What I’m doing wrong?
Thanx.
When I run the following command,
#/usr/local/bin/sr_server &
messages keep pumping onto my console, is that normal or not?
Also, when I do sr_client yes.wav, I did not receive any result. Anyone know why?
INFO: uttproc.c(1186): Batchmode
WARNING: “uttproc.c”, line 739: NO AGC
WARNING: “search.c”, line 2587: UTTERANCE TOO SHORT; IGNORED
SERVER RESULT:
What’s wrong?
Hi!
The asterisk-sphinx.zip file has disappeared from http://www.kohat.pk/asterisk-sphinx.zip
Could anyone upload it to any server or send my by email (gamezer0@DELETETHISgmail.com), please?
Thanks.
Gamezer,
You can download Sphinx server, client and AGI files from here:
http://www.syednetworks.com/asterisk-sphinx.rar
Was looking for a guide that how to LumexVox AGI script with Asterisk. I’d appreciate if somebody post about LumenVox Speech Recognition. Thanks
has anyone come up with a solution for the issue described in comment 1 by kevin. It seems that there is not much information on this on google.
help appreciated
Well i figured out the problem after some hours.
you apparently need to create symbolic links
in /usr/lib/ for the modules that are not found by per.
the modules are located in /usr/local/sphinx/lib
or you could add /usr/local/sphinx/lib to /etc/ld.so.conf and then type ldconfig, which will enable the library loader to find the needed libs..