Installing Jasper on the Beaglebone Black

I have been following the Jasper project for a while now. I installed it a couple months ago on my raspberry pi, and got some rudimentary features working. Now that Pi is in full service running a home automation system and I have received my next single board computer, the Beaglebone black . Having nothing better to do with it, I decided to see how far Jasper has come and try to get it running on the black. below are my efforts.

Here is my setup;

A Beaglebone black rev C running the 2014-05-14  SD card Debian image. My sound card is a Logitech usb headset, but any USB soundcard should work. I will eventually be getting this one and will report back once it arrives.

I started with the default SD card Debian image for the BBB available here. Although you shouldn’t have any problem installing it directly on rev C boards with 4 gb of emmc.  – This has not been tested.

As for accessing the BBB command line, I will be using an ssh session as root through putty. The cloud 9 ide should work, but is not tested at this point.

Much of the documentation in this page is ripped straight from here and has has small changes that enable it to run on the BBB. (To a point, not everything is working yet)

Here goes nothing.

Manual Install

Boot up your BBB and ssh into it.

Run the following commands to update BBB

sudo apt-get update
sudo apt-get upgrade -y
cd /opt/scripts/tools/
git pull
sudo ./
sudo reboot

You will eventually have to reboot for the update to complete. If anything fails, such as you getting an “out of space” message, you may need to pop the sd card into a Ubuntu machine and expand the filesystem with gparted.

Install some useful tools.

sudo apt-get install vim git-core espeak python-dev python-pip bison libasound2-dev libportaudio-dev python-pyaudio --yes

This is where some things differ between the Rpi and BBB. The Rpi has an audio out port, the BBB does not. (The HDMI does, but I doubt that you’ll be using that) That means that we have to disable the hdmi and make our usb card the default device (card 0)

To disable the hdmi sound card, plug the BBB into your computer with a usb cable. It should show up as a regular flash drive. Find the file called;


Open up the file in your favorite text editor (I use Notepad++) and find the section saying

##Disable HDMI

Remove the # from the start of the second line. The section should now look like

##Disable HDMI

That’s it! Save the file and reboot the BBB.

Once your BBB reboots, plug in your USB sound card and run this command;

aplay -l

You should get a response something like

**** List of PLAYBACK Hardware Devices ****
card 1: Headset [Logitech USB Headset], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

We need to allow the USB sound card to become card 0.
(configuring the sound card probably does not need to be done as we will need to switch out the hw variable in the aplay commands jasper uses shortly anyways. I am just documenting what I have done in my efforts so far.)

Let’s open up an ALSA configuration file in vim:

sudo vim /etc/modprobe.d/alsa-base.conf

Comment out the following line:

options snd-usb-audio index=-2

It should now look like this:

#options snd-usb-audio index=-2

The raspi commands are slightly different from this, instead of commenting out the like, they changed -2 to 0. When I tried this and reloaded alsa (next step) my sound card dissapeared from the # aplay -l command, but could be verified that it was still connected via # lsusb.

Back in the shell, run:

sudo alsa force-reload
aplay -l

You should now see something like

root@beaglebone:~/jasper# sudo alsa force-reload
Unloading ALSA sound driver modules: snd-usb-audio snd-hwdep snd-usbmidi-lib.
Loading ALSA sound driver modules: snd-usb-audio snd-hwdep snd-usbmidi-lib.
root@beaglebone:~/jasper# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Headset [Logitech USB Headset], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Next, test that recording works (you may need to restart your BBB) by recording some audio with the following command:

arecord temp.wav

Make sure you have speakers or headphones connected to the audio jack of your BBB. You can play back the recorded file:

aplay temp.wav

This is slightly different then the command in the raspi setup docs, which is

aplay -D hw:1,0 temp.wav

This will cause a problem later as the sound-card HW id’s are hardcoded into Jasper (Developers- please put mic and speaker id’s into a config file!!) We will have to go into the jasper scripts and switch the id’s out manually later.

If all of the steps above succeed, continue on.

Add the following line to the end of ~/.bash_profile (you may need to run touch ~/.bash_profile if the file doesn’t exist already):

export LD_LIBRARY_PATH="/usr/local/lib"
source .bashrc

And this to your ~/.bashrc or ~/.bash_profile:

export PATH

With that, we’re ready to install the core software that powers Jasper.

Install Pocketsphinx

We will be installing jasper in the home folder. Putting it in a folder has not been successfully tested.

cd ~

Jasper uses Pocketsphinx for voice recognition. Let’s download and unzip the sphinxbase and pocketsphinx packages:

tar -zxvf sphinxbase-0.8.tar.gz
tar -zxvf pocketsphinx-0.8.tar.gz

Now we build and install sphinxbase:

cd ~/sphinxbase-0.8/
./configure --enable-fixed
sudo make install

And pocketsphinx:

cd ~/pocketsphinx-0.8/
sudo make install

Once the installations are complete, restart your BBB.

Install CMUCLMTK, OpenFST, MIT Language Modeling Toolkit, m2m-aligner, Phonetisaurus

Note that some of these installation steps take more time to complete than previous steps.

Begin by installing some dependencies:

sudo apt-get install subversion autoconf libtool automake gfortran g++ --yes

Next, move into your home (or Jasper) directory to check out and install CMUCLMTK:

svn co
cd cmuclmtk/
sudo ./ && sudo make && sudo make install
cd ..

Then, when you’ve left the CMUCLTK directory, download the following libraries:


Untar the downloads:

tar -xvf openfst-1.3.3.tar.gz
tar -xvf phonetisaurus-0.7.8.tgz
tar -xvf mitlm-0.4.1.tar.gz
tar -xvf g014b2b.tgz

Build OpenFST: !!! Do not attempt this step, It will take a really long time and fail !!!

cd openfst-1.3.3/
sudo ./configure --enable-compact-fsts --enable-const-fsts --enable-far --enable-lookahead-fsts --enable-pdt
sudo make install # come back after a really long time

This is where things failed for me. I eventually had to try a combination of adding a swap file and following the instructions in this bug report. Commands follow.

Create and mount a swap file

These commands will be added later - once jasper gets to the point where it is processing audio on the BBB. 
if you run into this tutorial before it is updated, just follow the swap file guide linked above.

After these compiles are done, the swap-file is no longer needed. It can be removed after everything is built.  Otherwise it may wear down your flash storage.

I’m not sure if this next part is actually needed, as the swap file was the last problem I solved before openfst compiled, (if someone could confirm this that would be great, otherwise once everything is working I’ll install jasper following all instructions in this guide.) but I’m documenting everything anyway with the hope that this will be extremely easy to turn into a guide for jasper on the BBB.

Change the gcc compiler

sudo apt-get install gcc-4.4 g++-4.4 cpp-4.4

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.3 10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 20

sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.3 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.4 20

sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
sudo update-alternatives --set cc /usr/bin/gcc

sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
sudo update-alternatives --set c++ /usr/bin/g++

Now that we have the right compiler and enough memory, go ahead and install openfst. I am using screen here as well as I don’t want an accidental ssh closure to stop my build. It will take a couple of hours.

cd openfst-1.3.3/
cpufreq-set -g performance # Increase cpu frequency to 1000mhz for faster compiling. Usually set at 300 - 600mhz
sudo ./configure --enable-compact-fsts --enable-const-fsts --enable-far --enable-lookahead-fsts --enable-pdt
sudo make install # come back after a really long time

OpenFST should compile correctly after this. If you have to leave, disconnect from the screen session using:


And reconnect once you log in again using

screen -r

Once the compile is finished, move onto the next steps.

Install experimental m2m

cd ~
nano /etc/apt/sources.list

and paste

deb experimental main contrib non-free

to the bottom of the file.

press CTRL + X , then enter to save and close. we have now added experimental packages to our sources.

install the experimental package

apt-get update
apt-get -t experimental install m2m-aligner


cd ..
cd mitlm-0.4.1/
sudo ./configure
sudo make install

Build Phonetisaurus:

cd ..
cd phonetisaurus-0.7.8/
cd src
sudo make

Move some of the compiled files:

sudo cp ~/jasper/phonetisaurus-0.7.8/phonetisaurus-g2p /usr/local/bin/phonetisaurus-g2p

Build Phonetisaurus model: (If you get dictionary errors, reboot the black and rebuild this)

cd g014b2b/

Finally, rename the following folder for convenience:

mv ~/g014b2b ~/phonetisaurus

At this point, we’ve installed Jasper and all the necessary software to run it. Before we start playing around, though, we need to configure Jasper and provide it with some basic information.

You can follow the normal jasper instructions from here. things are somewhat working (jasper starts) but there seems to be some bitrate and soundcard issues still.


Posted on September 22, 2014, in Uncategorized and tagged , , , , . Bookmark the permalink. 3 Comments.

  1. Any updates on the final issues? i’ve been working on getting it downloaded onto a laptop running linux, the step by step guide from jasper works all the way through but im running into what I assume to be the same issues you are at the end. Jasper starts up but wont run due to the sound issues.

    • Not really. The beagle-bone / jasper project has been shelved for a little while now. I do plan to try again and update if I’m successful this Christmas break though.
      I do know though that the way jasper handles audio hardware has changed significantly to be more compatible with other systems since I wrote this post. (Github issue) And also that some people have gotten jasper working on Ubuntu / fedora, and I’m pretty sure that’s been documented over here: Google group

      Sorry that I can’t be much help here. I haven’t been following the project as closely lately and I am otherwise swamped with other work.
      Good luck, let me know if you can get it working.

  2. play with sudo, configure .asound file , I lhave et my sound card as card 1 . Working fine

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: