Flite text-to-speech using Visual C++ 6.0

The purpose of this document is to describe one way of using flite 1.2 from Visual C++. (This is because apparently you can't compile flite 1.2 with Visual C++ : "Visual C++ 6.0 is known to fail on the large diphone database files."). It's actually very easy to use Flite from Visual C++, just build flite with MinGW and link in the libs that are created.

The files that you can download on this page are either from or generated from flite-1.2-release. The files are all under the flite license.

I really would recommend flite if you just want to use text-to-speech. It requires a lot less memory than festival and you can fire off many threads to flite and they can play concurrently. Apparently festival is not thread safe.

For the impatient just download the libs: libflite_cmu_us_kal.a, libflite_usenglish.a, libflite_cmulex.a, libflite.a (right click, save target as). And download and unzip include.zip, and look at the code example below, otherwise you can build the libs from flite 1.2 source. If you don't care about efficiency, you might as well do it like this, using flite.exe (save it to c:\), and it even works with MinGW.

Building Flite using MinGW

I used MinGW since it creates a binary that is not dependent on the Cygwin dll.

Using Flite in a Visual C++ program

In Project, Settings, under the C++ tab, under Preprocessor, add the path to the include directory of flite ( or the include directory from include.zip). Under the link tab add the path to the lib directory of flite ( or just put your downloaded .a files in the same directory as the .dsw file). Then add the following to "Object/library modules": libflite_cmu_us_kal.a libflite_usenglish.a libflite_cmulex.a libflite.a winmm.lib Put a .\ in front of the flite ones if they are in the .dsw directory. You can replace libflite_cmu_us_kal.a with libflite_cmu_us_kal16.a if you want. Now you can use code as follows:

#include "flite.h"

extern "C"
	cst_voice* register_cmu_us_kal();
cst_voice* voice;

int main(void)
	flite_text_to_speech("hello world",voice,"play");
	return 0;

Please let me know if there are any errors in, or possible improvements to, this document. Please also note that this stuff comes with no warranty and I am not sure if it works correctly. My email address is: mataav@yahoo.co.uk

SourceForge.net Logo