Installing PocketSphinx on Raspbian (Jessie)

Installing PocketsSphinx on Raspbian is very similar to install PocketSphinx on Debian, the only differerence being that Raspbian doesn't by default include the essential packages for building PocketSphinx, and Pulse Audio isn't installed.

Here's how to install PocketSphinx on Raspbian (Jessie).

Install the Debian packages

sudo apt-get install swig python-dev libpulse-dev

sudo apt-get install gstreamer0.10-pulseaudio libao4 libasound2-plugins libgconfmm-2.6-1c2 libglademm-2.4-1c2a libpulse-dev libpulse-mainloop-glib0 libpulse-mainloop-glib0-dbg libpulse0 libpulse0-dbg libsox-fmt-pulse paman paprefs pavucontrol pavumeter pulseaudio pulseaudio-dbg pulseaudio-esound-compat pulseaudio-esound-compat-dbg pulseaudio-module-bluetooth pulseaudio-module-gconf pulseaudio-module-jack pulseaudio-module-lirc pulseaudio-module-lirc-dbg pulseaudio-module-x11 pulseaudio-module-zeroconf pulseaudio-module-zeroconf-dbg pulseaudio-utils oss-compat -y. 

The swig and python-dev packages were required to compile sphinxbase. While libpulse-dev was necessary to successfully execute the Ruby code using the pocketsphinx-ruby gem.

Download and compile the PocketSphinx source code

git clone https://github.com/cmusphinx/sphinxbase.git

cd ~/sphinxbase

./autogen.sh 
./configure
make clean all
make check
sudo make install

Note: After compilation I observed sphinxbase failed 1 unit test. I ignored the unit test result and continued on.

git clone https://github.com/cmusphinx/pocketsphinx.git

cd ~/pocketsphinx

./autogen.sh 
./configure
make clean all
make check
sudo make install

Running the PocketSpinx Ruby gem

Before you can execute the pocketsphinx-ruby gem it is necessary to set the library paths e.g. :

LD_LIBRARY_PATH=/home/james/sphinxbase/src/libsphinxbase/.libs/:/home/james/sphinxbase/src/libsphinxad/.libs/:/home/james/pocketsphinx/src/libpocketsphinx/.libs/
export LD_LIBRARY_PATH

Note: Remember to modify the above lines to match the directory where you stored sphinxbase and pocketsphinx.

I installed the ruby package as well as the ruby-dev package.

type irb

Copy and paste the following code into the IRB sesssion:

require 'pocketsphinx-ruby'

Pocketsphinx::LiveSpeechRecognizer.new.recognize do |speech|
  puts speech
end

Configuring the microphone

Within the command line type alsamixer and select the sound device, and change the input catpure volume level if required.

I tested the microphone audio quality using arecord e.g. arecord -d 5 -t wav sound.wav.

Resources

Tags:
Source:
1228hrs.txt
Published:
18-01-2016 12:28