Website Logo. Upload to /source/logo.png ; disable in /source/_includes/logo.html

Chris Meier

Software Developer and Co-founder of FoodChain

Installing PocketSphinx for Jasper on the Raspberry Pi B+

This guide is meant to help anyone that is trying to put Jasper on the B+ and is having trouble installing PocketSphinx. I couldn’t get the Phonetisaurus model to build and I was stuck for a few days, mainly due to the fact that these programs take a long time to build. The issue I ran into with Phonetisaurus was some invalid instruction errors. I searched the internet and was able to find this post

The problem is that Phonetisaurus, m2m-aligner and MITLM contained in the experimental repository supplied in the instructions are build for armv7. The B+ is armv6. This explains the invalid instruction errors I was getting.

If you come across this after trying other methods,  you must uninstall any packages that came from Debian Experimental. If you are just starting out, you can find the Jasper instructions here.

Let’s Begin: Follow the instructions until you get to the part where you have to install Phonetisaurus, m2m-aligner and MITLM.

Instead of:

1
2
3
sudo su -c "echo 'deb http://ftp.debian.org/debian experimental main contrib non-free' > /etc/apt/sources.list.d/experimental.list"
sudo apt-get update
sudo apt-get -t experimental install phonetisaurus m2m-aligner mitlm libfst-tools

Do:

1
2
3
4
5
6
7
# add repo
sudo su -c "echo 'deb http://cognomen.co.uk/apt/debian jessie main' > /etc/apt/sources.list.d/cognomen.list"
# import pgp key
gpg --keyserver keyserver.ubuntu.com --recv  FC88E181D61C9391C4A49682CF36B219807AA92B && gpg --export --armor keymaster@cognomen.co.uk | sudo apt-key add -
# update
sudo apt-get update
sudo apt-get install phonetisaurus m2m-aligner mitlm libfst-tools libfst1-plugins-base libfst-dev

You can then build the Phonetisaurus model according to the official instructions:

1
2
3
4
5
wget https://www.dropbox.com/s/kfht75czdwucni1/g014b2b.tgz
tar -xvf g014b2b.tgz
cd g014b2b/
./compile-fst.sh
cd ..

This will take a couple of hours, so it’s best if you leave it and come back later.

Then rename the directory for convenience:

1
mv ~/g014b2b ~/phonetisaurus

The PocketSphinx HMM needs to be installed explicitly:

1
sudo apt-get install pocketsphinx-hmm-en-hub4wsj

Finally, set the locations of the HMM and the FST model in your profile.yml

1
2
3
4
stt_engine: sphinx
pocketsphinx:
 fst_model: '../phonetisaurus/g014b2b.fst'                             
 hmm_dir: '/usr/local/share/pocketsphinx/model/hmm/en_US/hub4wsj_sc_8k'

You should be good to go with PocketSphinx. You can further configure Jasper following the instructions here.

When your configuration is complete, just restart your Pi with your microphone plugged in and Jasper will now work!