Archive for April, 2012

Date: April 23rd, 2012
Cate: development
2 msgs

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:\sdks\flite-1.4-release\lib).

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

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


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


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:

    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:

  • When “flite_text_to_speech” is called, the game pauses while the speech is read. I’ll have to find out how to resolve this.
  • I was unable to find any obvious way to adjust the speech’s volume.
  • The speech is routed not through Doom 3’s audio system, but through Flite’s audio system. I’m guessing this may cause surprise gotchas and jankiness down the road if I let them remain separate as they are now.

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