2012-01-05

CMU Sphinx under Ubuntu/Linux

CMU Sphinx is a set of tools for automatic speech recognition. Here's an example of how to install it and a simple C program with comments.

More information can be found here:
http://cmusphinx.sourceforge.net/


Gstreamer

This example requires Gstreamer. Prior to installation, you will have to download and install it.

$ sudo apt-get install gstreamer0.10-plugins-base

Installation

*) Download the latest sources of sphinx base and pocket sphinx (currently, version 0.7):
http://sourceforge.net/projects/cmusphinx/files/sphinxbase/
http://sourceforge.net/projects/cmusphinx/files/pocketsphinx
*) unpack and install
$ tar xvf sphinxbase-0.7.tar.gz
$ cd sphinxbase-0.7
$ ./configure
$ make
$ sudo make install
$ tar xvf pocketsphinx-0.7.tar.gz
$ cd pocketsphinx-0.7/
$ ./configure
$ make
$ sudo make install

*) Make sure you have paths configured correctly in your ~/.bashrc file:
export LD_LIBRARY_PATH=/usr/local/lib
export PATH=$PATH:/usr/local/lib:/usr/local
Test your installation

Download a simple program and type
$ ./run.sh
to compile and run.
It will simply recognize a few words and display them (like "hello world", "who are you".
https://sites.google.com/site/wessmansourcecode/pocket.example.tar.gz

How does it work?Take a look at the web site of the CMPSphinx team.My intentions are to publish more of my knowledge later on...

14 comments:

  1. Thank you for your post
    I run these commands step by step.
    Installation finished successfully, but when I run ./run.sh these messages showed me
    ---------------------------
    Package gstreamer-0.10 was not found in the pkg-config search path.
    Perhaps you should add the directory containing `gstreamer-0.10.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'gstreamer-0.10' found
    Package gstreamer-0.10 was not found in the pkg-config search path.
    Perhaps you should add the directory containing `gstreamer-0.10.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'gstreamer-0.10' found
    pocket.c:2:21: fatal error: gst/gst.h: No such file or directory
    compilation terminated.
    -- :1
    -----------------------
    please help me for it.

    ReplyDelete
    Replies
    1. In addition to the other gstreamer installations already described here, I had to install libgstreamer.

      $ sudo apt-get install libgstreamer0.10-dev

      Delete
  2. Thank you for your comment.
    In order to be able to compile, you will have to install Gstreamer.
    The easiest way to download it would be through the APT sources.

    $ sudo apt-get install gstreamer0.10-plugins-base

    ReplyDelete
  3. After installing the gstreamer plugin , when tried to compile and run a sample program given on website it shows an error as:
    --------- ERRROR: ----------
    Unable create vader.
    Init failed...

    I read a post regarding the error and it said that plugins are not correctly installed. As I am a beginner, I don't know anything about how to resolve this.. Please help me through this.
    Thanks in advance

    ReplyDelete
    Replies
    1. This probably means that gstreamer can't locate the gstpocketsphinx plugin.
      Type
      $ gst-inspect vader
      to see if the plugin is detected.

      If not, try first to remove the registry file which (if running gstreamer-0.10) is located at ~/.gstreamer-0.10/registry-$ARCH.bin
      ie:
      $ rm ~/.gstreamer-0.10/registry.x86_64.bin

      If the gst-inspect still does not detect your plugin, try to configure the resources with the --prefix=/usr flag, which will change the location of the installation of headers and libs. IE:
      [..]/sphinxbase-0.7$ ./configure --prefix=/usr
      $ make && sudo make install
      and
      [..]/pocketsphinx-0.7$ ./configure --prefix=/usr
      $ make && sudo make install

      Repeat the removal of the plugins registry file afterwards.

      Delete
    2. Try installing this package: gstreamer0.10-pocketsphinx

      On Ubuntu:
      sudo apt-get install gstreamer0.10-pocketsphinx

      Delete
  4. Hi,

    I'm running into the same problem as Neha. However, when I try to make install with the prefix '/usr', I get the following error:

    "libtool: install: error: cannot install `libpocketsphinx.la' to a directory not ending in /usr/local/lib"

    Any ideas as to why that occurs?

    ReplyDelete
  5. I am having similar issues. I delete the registeries and I have made it install in /usr but it still does not detect vadar

    ReplyDelete
  6. If anyone has this error:

    --------- ERRROR: ----------
    Unable create vader.

    Try installing this package: gstreamer0.10-pocketsphinx

    On Ubuntu:
    sudo apt-get install gstreamer0.10-pocketsphinx

    and try running the example again.

    ReplyDelete
    Replies
    1. If you install gstreamer and the gst-plugins from source, you could chose to configure by setting the prefix to your /usr directory
      $ ./configure --prefix=/usr

      By doing this and adding the same prefix to your pocketsphinx-configuration, the sphinx-installation should be able to detect your gst-installastion through pkg-config.

      Check your [pocketsphinx-dir]/config.log for details (search for "gst").

      One can also try to remove your plugin registry file
      $ rm ~/.gstreamer-0.10/registry.*

      Delete
  7. how do i compile a code written by me?

    ReplyDelete
  8. hello thank u for this tutorial..it's really interesting but please i want to run my own example instead of this one given here..so for that i have to create my corpus and dictionary and language files right?i did that using language modelling tool provided by sphinx cmu http://www.speech.cs.cmu.edu/tools/lmtool-new.html .however it gives me only language file and dictonary file and vocabulary file..from where i can get token file and what is the use of this file?and if i replaced those files given in that example by mine it will work with the same c program???please help me

    ReplyDelete
  9. Great tutorial . I have the same question. I want to learn to recognize new words. Where do I put the language file and dictonary file? Could you please tell us step by step?

    ReplyDelete
  10. hello, when i run ./run.sh then its start loading...even if i speak in microphone,...then it does not recognize it...in sequence it starts to show WHO,AM....
    plz help

    ReplyDelete