FLITE synthesized speech


For the past couple days I’ve been working on getting synthesized speech into the Doom 3 engine. After wrangling with it this morning, I got it up and running. There’s still a few kinks to work out (I’ll get to that later), and I haven’t yet decided whether to go forward with it, but I think there’s a lot of promise and applicability toward games.

The speech system I used was an open-source library called Flite. Most of my previous posts have been design and art oriented, so I thought I’d give a technical overview on how to integrate speech into your project. I’m still fairly green around C++, so this is probably more helpful for me than you.

  1. Set up the environment. In the project’s Library Directories, add Flite’s “lib” folder (in my case, C:/sdksflite-1.4-release/lib).

  2. In the project’s Include Directories, add Flite’s “include” folder (in my case, C:/sdksflite-1.4-release/include).

  3. In the project’s Additional Dependencies, add:

    fliteDll.lib 
    

    cmu_us_rms.lib

  4. Copy these files into your game’s folder:

    fliteDll.dll
    

    cmu_us_rms.dll

  5. The environment is now ready. Now we can dig into the code. Open up whatever file you’d like to include speech in. Add at the top of the .cpp file:

    extern "C"
    

    { #include “flite.h” cst_voice *register_cmu_us_rms(); cst_voice *fliteVoice; };

  6. In a function where things are initialized, add:

        flite_init() fliteVoice = register_cmu_us_rms();

  7. And finally, we get to play the audio. Call this line when you want the audio to play:

    flite_text_to_speech("Baboo wizard.", fliteVoice, "play");
    

Done!  Now your game will say “baboo wizard” at the most exciting and inopportune times during gameplay. I get chills just thinking about it.

This was an extremely basic “hello world” example, so a few things to keep in mind:

I’m now looking forward to playing tons of games featuring Mr. Robot Voice saying incredible things to me. Go forth and get crackin’.