Friday, April 17, 2009

Getting Started with Sphinx4 and Eclipse

I started reading the Getting Started page of Sphinx4. After downloading both source code and binaries it was time to set our environment. I have always used and enjoyed working on Eclipse. So went for setting up Eclipse environment.

Pre-requisites: Eclipse (Callisto, Europa or Ganymede). JRE 1.4+
Follow these steps to setup your development environement for Eclipse IDE:
  1. Extract Sphinx4 source and binaries in folder. I have /Speech/Sphinx/sphinx4-1.0beta2.
  2. Create a Empty Java Project titled 'sphinx' or any name you wish to.
  3. In the Package Explorer, right click on Project and select 'Build Path -> Link Source'
  4. A Dialog Box will appear asking you to enter the source folder from your filesystem. navigate your path to /Speech/Sphinx/sphinx4-1.0beta2/src/sphinx4.
  5. Eclipse parses entire folder structure recursively and also names your source folder.
  6. Click Next and Finish. A new source folder is now linked with your project.
  7. It will contain lot of errors as libraries are not been added yet.
  8. Add /lib/js.jar, lib/tags.jar and lib/jsapi.jar to your project classpath by right-clicking project and selecting 'Build Path -> Configure Build Path -> Libraries'.
  9. Eclipse then refreshes the workspace and all errors are nullified.

Sphinx4 also provides you with a handful of sample programs. I found every sample program very useful and it covered most of the details needed to learn Sphinx4.

To Setup the environment for using the samples and viewing the source code, you can follow these steps.

  1. Create another new project and title it as 'sphinx-demos'
  2. Right click and Link this Source folder: /Speech/Sphinx/sphinx4-1.0beta2/src/apps
  3. Add the missing Libraries: /lib/js.jar, lib/tags.jar and lib/jsapi.jar and lib/sphinx4.jar to your project classpath
  4. Every demo is a simple Java file. To test any demo, just right-click select Run -> Run as Java Application File.

There you go. You are now ready to learn Sphinx4 with proper development environment setup.

Sphinx Project gives you access to entire source code of Sphinx.
Sphinx-demo Project gives you access to all the demo apps for Sphinx.

13 comments:

  1. Do you know if sphinx 4 supports making applications that convert text to speech?

    ReplyDelete
  2. No. Sphinx is only ASR. Go for freeTTS or any other tool.

    ReplyDelete
  3. hey followed your steps but in project manager it shows a cross mark.. it think project is unable to build properly..

    ReplyDelete
  4. Hi, i tried setting up Eclipse 3.6.2 with sphinx4 and I'm having troubles n number 7 to the end. It seems eclipse still doesn't recognize the libraries I added and still has a lot of warnings.
    Same with doing it with a demo, when I run the sample programs from sphinx4 it only ends up having errors about declarations. Please help :(

    ReplyDelete
  5. @poleleng: I had to change Java Compiler to level 1.5 or higher and the errors disappeared... maybe same to you?

    ReplyDelete
  6. hey is there any way to convert the simple words to the cmudict like phonetic word?

    like this?
    ABANDONS AH B AE N D AH N Z


    What this conversion is called??

    its used in sphinx4 speech recognition to recognize word

    ReplyDelete
    Replies

    1. its called grapheme to phoneme conversion, and CMU hosts a tool that will do it for you online, at http://www.speech.cs.cmu.edu/tools/lmtool-new.html

      Delete
  7. This comment has been removed by the author.

    ReplyDelete
  8. Hi, good work!
    This page : http://cmusphinx.sourceforge.net/sphinx4/index.html#download_and_install

    says that the .bin package is a subset of the .src package. So, why do I need to download both?

    ReplyDelete
  9. Established transportation infrasctructure for a plethora of lifestlye, dining and entertainment.
    the interlace

    ReplyDelete
  10. i am getting Error on
    demos -->jsapi.tags --->live connect ---->

    on intiating library

    import javax.speech.recognition.RuleGrammar;

    And actualluy i have imported all library (jsapi,tags,sphinx4..)

    ReplyDelete