[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Flite is a library that we expected will be embedded into other applications. Included with the distribution is a small example executable that allows synthesis of strings of text and text files from the command line.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The example flite binary may be suitable for very simple applications. Unlike Festival its start up time is very short (less that 25ms on a PIII 500MHz) making it practical (on larger machines) to call it each time you need to synthesize something.
flite TEXT OUTPUTTYPE |
If TEXT
contains a space it is treated as a string of text and
converted to speech, if it does not contain a space TEXT
is
treated as a file name and the contents of that file are converted to
speech. The option -t
specifies TEXT
is to be treat
as text (not a filename) and -f
forces treatment as a file.
Thus
flite -t hello |
will say the word "hello" while
flite hello |
will say the content of the file ‘hello’. Likewise
flite "hello world." |
will say the words "hello world" while
flite -f "hello world" |
will say the contents of a file ‘hello world’. If no argument is specified text is read from standard input.
The second argument OUTPUTTYPE
is the name of a file the output
is written to, or if it is play
then it is played to the audio
device directly. If it is none
then the audio is created but
discarded, this is used for benchmarking. If OUTPUTTYPE
is
omitted, play
is assumed. You can also explicitly set the
outputtype with the -o
flag.
flite -f doc/alice -o alice.wav |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Each voice in Flite is held in a structure, a pointer to which is
returned by the voice registration function. In the standard
distribution, the example diphone voice is cmu_us_kal
.
Here is a simple C program that uses the flite library
#include "flite.h" cst_voice *register_cmu_us_kal(); int main(int argc, char **argv) { cst_voice *v; if (argc != 2) { fprintf(stderr,"usage: flite_test FILE\n"); exit(-1); } flite_init(); v = register_cmu_us_kal(); flite_file_to_speech(argv[1],v,"play"); } |
Assuming the shell variable FLITEDIR is set to the flite directory the following will compile the system (with appropriate changes for your platform if necessary).
gcc -Wall -g -o flite_test flite_test.c -I$FLITEDIR/include -L$FLITEDIR/lib -lflite_cmu_us_kal -lflite_usenglish -lflite_cmulex -lflite -lm |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Although, of course you are welcome to call lower level functions, there a few key functions that will satisfy most users of flite.
void flite_init(void);
This must be called before any other flite function can be called. As of Flite 1.1, it actually does nothing at all, but there is no guarantee that this will remain true.
cst_wave *flite_text_to_wave(const char *text,cst_voice *voice);
Returns a waveform (as defined in ‘include/cst_wave.h’) synthesized from the given text string by the given voice.
float flite_file_to_speech(const char *filename, cst_voice *voice, const char *outtype);
synthesizes all the sentences in the file ‘filename’ with
given voice. Output (at present) can only reasonably be, play
or none
.
float flite_text_to_speech(const char *text, cst_voice *voice, const char *outtype);
synthesizes the text in string point to by text
, with the given
voice. outtype
may be a filename where the generated waveform is
written to, or "play" and it will be sent to the audio device, or
"none" and it will be discarded. The return value is the
number of seconds of speech generated.
cst_utterance *flite_synth_text(const char *text,cst_voice *voice);
synthesize the given text with the given voice and returns an utterance from it for further processing and access.
cst_utterance *flite_synth_phones(const char *phones,cst_voice *voice);
synthesize the given phones with the given voice and returns an utterance from it for further processing and access.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated by root on July, 19 2007 using texi2html 1.78.