This is another baby step on how one can learn about Sphinx 4. As I mentioned in the previous post, it is nicer to use an IDE when you use Java code. Since I have some exposure in Eclipse, I choose it as an example on how to setup a Sphinx 4 build.
Before I go on there were many posts, written by others, discuss the procedure. You may take a look of them as well.
- Getting Start with Sphinx4 from “Speech Recognition Woe” written by “Amit S”
- Setting up Development Environment from CMUSphinx Blog written by GSOCer. (If you know who write it, let me know so I can properly credit)
Eclipse as a Development Environment
The compilation in High Level
- Downloading Sphinx4 source code
- Install JSAPI.
- Incorporate the proper libraries.
- Do the build.
- A plain simple svn command is fine, downloading the tarball will give you a more stable version. I will suggest a more attractive option is to use SVN module of Eclipse, subclipse. To do that, you may want to follow “Downloading Subclipse” from Setting up Development Environment . (Notice that there was a typo in the post should be “tigris” instead “trigris” on the location field.)
- Once you finished checking out Subclipse. Start a new Project
- New -> Project -> SVN -> Checkout Projects from SVN
- Choose “Create a New Repository Location”
- Remember to only download trunk/sphinx4 (Note: there are many branches and location, for starter, you will be interested how the trunk look like.)
Install JSAPI
I tried the install of both Windows Vista and Linux. In windows, go to
> jsapi.exe
Then accept the license.
In Linux, in the same directory. do
> sh jsapi.sh
One common problem for Linux here: you need to install uudecode if you want to install jsapi. In that case, try to install sharutil. On Ubuntu, it works for me when I do
> apt-get install sharutil
At this point you should see your directory should have a file named jsapi.jar
Incorporate the proper libraries
This is another part which took me a while. Before you go on to configure your path, you need to do one more step to make to configure libraries. In Eclipse, right click you Sphinx4/lib directory and choose Refresh first. This will make jsapi.jar appears your Package Explorer. It should look like this:
When JSAPI.jar is properly installed |
Then, you can change the build path, go to your project again, right click and choose Build Path -> Configure Build, Libraries, choose Add Jar, then add the libraries you need.
Now…. wait, what are the jar files we need again?
Yeah, so this is another place which can cause confusions. In fact, because Sphinx has expanded its code from time to time, so the answer of which jar files to add depends. As of Dec 28, 2012, you should add
- junit
- jsapi
- js
- fst
This list will likely to grow in future. I am also pretty sure you might need to do different things if you want to compile in a different setting or write your own code.
Do the build
In modern Eclipse, building should be automatic, what you should see should be 0 errors but many warnings. I generally don’t approve of warnings but as a developer, it’s pretty tough to eliminate them all.