Sunday, June 8, 2008

Speak Ada! Speak!

Text to speech was a valuable tool in a recent class. It made for great debugging information when no visual interaction was possible, and was a helpful feature in the final application. The text to speech system used there was easy to program dedicated hardware. I may be a hardware junkie, but I'm pretty sure I can get by with a software solution.

After a bit of searching around I found Festival. Festival is available as a package for Linux and seems to be pretty mature. I installed festival and read through a tutorial on it. Some reading needed to be done to understand the parameters in GNAT.OS_Lib. After a bit of examining the code it made sense.

First needed to make a script to translate the way Ada's spawning passes parameters into the way Festival takes input.

Simple shell script that needs to be saved and be made executable. "./ "your text goes here"" will call festival.

The Ada part was a bit kludgy with how the parameters were passed, but nothing too bad.

I'd like to think that is pretty straightforward...

I doubt this is the most efficient way. Some magic with bash scripts could easily be more efficient. Instead of re-spawning Festival with every call another possible approach might be to use Festival's --server and send over the network. I've dabbled with interfacing directly with the Festival C++ API, but my understanding of C++ compiler messages is limited. I had to do some shoehorning to get a gcc on this system, so that might be a problem as well.

It works, its simple, I'm happy.