Skip to content

Pocketsphinx and Python

Ziping Liu edited this page Jul 14, 2018 · 6 revisions

Pocketsphinx uses SWIG to generate python library.

Provide --with-swig-python command-line at configuration step to enable SWIG bindings.

See swig/python/test for usage examples. Below there is a shell script that shows how to properly setup PYTHONPATH variable to run examples right from the source tree. Run the script from within the swig/python/test directory.

#!/bin/sh
PYTHONPATH =  ../../../../sphinxbase/swig/python:../../../../sphinxbase/swig/python/.libs
PYTHONPATH += :../../python:../../python/.libs
PYTHONPATH=$PYTHONPATH /usr/bin/env python $@

After you install pocketsphinx with either make install or a package management system it should be sufficient to import the corresponding packages, no PYTHONPATH manipualations will be required:

import sphinxbase
import pocketsphinx
Clone this wiki locally