Windows users, please check more or less updated manual here:
I know you waited for the instruction for a long time, here it is. Cudos to Matthew Cooper who wrote this. These instruction should work on any GNU/Linux distributuion, for example on Fedora or Ubuntu. This is also written for phones have OS 2.2 or higher. Previous OS requires a different path to the sdcard, so it will be easy to adapt this guide.
Download and build pocketsphinx
To run pocketsphinx download the following from http://cmusphinx.sourceforge.net/wiki/download/
Then download PocketSphinxDemo archive from
PocketsphinxAndroidDemo – snapshot
Unzip all three folders into a place where you will remember to find them. It is necessary to unzip both pocketsphinx and sphinxbase folders into the same parent directory and rename them to just “sphinxbase” and “pocketsphinx” without version information.
Open up the terminal and type:
followed by your password. This will give you root access.
You will need swig later, so let’s install it. You need swig 1.3, for now we do not support newer swig like 2.0:
apt-get install swig
yum install swig
On Windows install swig according to the following document:
Now, cd into sphinxbase and run the following commands from command line:
cd into pocketsphinx and type:
On Windows you do not need to compile Sphinxbase, just unpack it.
Now cd into PocketSphinxDemo/jni folder
Open the Android.mk file, found in the jni folder, and change the SPHINX_PATH(line #5) to the parent folder holding pocketsphinx and sphinxbase.
from command line type:
Of course, substitude the real path to your ndk folder for the-path-to-your-ndk-folder
Now open Eclipse and import the PocketSphinxDemo.
In the Navigator View look for PocketSphinxDemo project. Right click on it and select properties. The properties screen will pop up and you will need to select Builders. In the Builders screen you will see SWIG and NDK build.
Click on NDK build and edit.
In the edit screen change the field Location to point to your ndk-folder you have on your machine. Click on the Refresh tab and select “The project containing the selected resource”
Click on the Build Options tab and deselect “Specify working set of relevant resources”
Apply changes and exit the configuration for NDK build.
Click on SWIG and edit.
You will not need to change the Location since downloaded swig at the start of the tutorial.
In the refresh tab select “The folder containing the selected resource”
In the Build Options tab deselect “Specifiy working set of relevant resources”
Apply changes and exit the configuration for SWIG.
Connect to your android phone and create the edu.cmu.pocketsphinx folder at
You can do this by opening terminal command and typing:
In shell type:
now cd into the edu.cmu.pocketsphinx folder that is located on your phone and create the following folder structure:
| ----> en_US
| ----> hub4wsj_sc_8k
Now type quit to leave adb shell.
While still in terminal you will need to push files from your computer onto the phone.
cd into pocketsphinx/model/hmm/en_US/ and type:
adb push ./hub4wsj_sc_8k /mnt/sdcard/edu.cmu.pocketsphinx/hmm/en_US/hub4wsj_sc_8k
Now cd into pocketsphinx/model/lm/ in your and type:
adb push ./en_US /mnt/sdcard/edu.cmu.pocketsphinx/lm/en_US
Now open the RecognizerTask.java found in
There are declared paths to a structure that is not valid on a 2.2 phone. We will need to change the paths so that they work correctly. Here is my code for the section.
Config c = new Config();
* In 2.2 and above we can use getExternalFilesDir() or whatever it's called
c.setString("-rawlogdir", "/mnt/sdcard/edu.cmu.pocketsphinx"); // Only use it to store the audio
If your model is different, you will have to use different paths, for example fo rthe mandarin model
Now build and run the project.