Posted by richunger
on January 9, 2008 at 6:46 PM PST
I'm getting back into the coding groove. Just for fun, last night I integrated the FreeTTS engine into the NetBeans Platform.
The module does 4 things:
- Integrates the engine
- Provides an extension point in its layer file for new voices
- Provides an options dialog for selecting a voice
- Provides an API hook for speaking a String in the current voice. Thus it would be trivial for a NB developer to add an action that says something (e.g. TTS.getDefault().speak("the time is " + getTimeString()) )
It was pretty easy. I spent most of the evening unraveling the weird manifest and classloader tricks the freeTTS project does. (IMHO there's no reason for a TTS library to create a classloader. Ever.)
A few hints to library writers:
- overloading the Main-Class attribute in your jar's manifest to do anything other than specifying a class with a main() method is a bad idea.
- If the way you read in your configuration requires a hack to work with webstart, you're making too many assumptions.
- It's not the library code's job to figure out which classloader a user-supplied extension is in. It's the users job to add their jar to the classpath. By trying to do it in the library's source code, you're just ensuring that anyone integrating your library in a way you didn't foresee can't do it.
Seriously, I spent just a few minutes getting FreeTTS to work on the command line, maybe half an hour writing the netbeans code, and several hours figuring out just why the heck the engine wasn't finding any voices when it ran in NetBeans.