Python Integration with PocketSphinx

Pocketsphinx is an open source recognition software created by CMU.  To implement Pocketsphinx in E-Motion robots require integration with Python, which is the goal of this blog post.

Download Pocketsphinx

$ sudo apt-get install -y python python-dev python-pip build-essential swig git
$ git clone --recursive https://github.com/bambocher/pocketsphinx-python

Install pocketsphinx-python

$ cd pocketsphinx-python
$ sudo python setup.py install

This installation will install sphinxbase, pocketsphinx, and also Python binding.

Running pocketsphinx-python

$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pocketsphinx import *
>>> from sphinxbase import *
>>> 

One can download more complex Python example from Mattze96 (unfortunately also named pocketsphinx-python). Create a new project directory and clone the Mettze96 repository. Look at the main_cli.py example. To run the main_cli.py example you may have to install pyaudio, like this:

$ sudo apt-get install python-pyaudio

References