Flite API error on windows

173 Views Asked by At

I build flite for windows, the code is:

#include "..\\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 = new_voice();
    flite_text_to_speech("This is a test",v,"play");
    return 0;
}

but I get the printf message "usage: ", if I delete that I get this "tried to access lexicon in -1 type val flite". I am on windows so I call project.exe without the arguments in the documentation. Do you know how to fix this ?

1

There are 1 best solutions below

1
On

As said in the comments you should remove the parameters count (argc) check.

In addition: When you call new_voice method you get uninitialized cst_voice and you still can't use it.

Thats why you get the error:

tried to access lexicon in -1 type val flite

It is mean the lex (cst_lexicon) is still uninitialized in the cst_voice structure.

I guess you need to do something like the following code:

cst_voice *register_cmu_us_no_wave()
{
    cst_voice *v = new_voice();
    cst_lexicon *lex;

    v->name = "no_wave_voice";

    /* Set up basic values for synthesizing with this voice */
    usenglish_init(v);
    feat_set_string(v->features,"name","cmu_us_no_wave");

    /* Lexicon */
    lex = cmu_lex_init();
    feat_set(v->features,"lexicon",lexicon_val(lex));

    /* Intonation */
    feat_set_float(v->features,"int_f0_target_mean",95.0);
    feat_set_float(v->features,"int_f0_target_stddev",11.0);

    feat_set_float(v->features,"duration_stretch",1.1); 

    /* Post lexical rules */
    feat_set(v->features,"postlex_func",uttfunc_val(lex->postlex));

    /* Waveform synthesis: diphone_synth */
    feat_set(v->features,"wave_synth_func",uttfunc_val(&no_wave_synth));

    return v;
}