1

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 ?

Richard
  • 106,783
  • 21
  • 203
  • 265
  • 1
    The code is checking for arguments, so calling it with none is always going to result in that usage message, Fix is to pass a file(name) on the command line. – Richard Aug 23 '18 at 07:02
  • @Richard But note nothing in the code accesses `argv` so passing a command line argument isn't going to help with the second error. – john Aug 23 '18 at 07:19
  • Did the original example worked? (with `register_cmu_us_kal(NULL)` instead of `new_voice()`) if yes, there is some problem with `new_voice()` – SHR Aug 23 '18 at 07:31
  • Not related, but it should be `#include "..\include\flite.h"` rather than `#include "..\\include\\flite.h"` – Jabberwocky Aug 23 '18 at 07:34
  • so many answers in one hour, I am going to try now, thankyou guys. @Jabberwocky that is not the problem – warriorforce Aug 23 '18 at 08:27
  • @Richard what file I need to pass, with text ? – warriorforce Aug 23 '18 at 08:36
  • @SHR in the original example I get the error register_cmu_us_kal: funciton does not take 1 argument – warriorforce Aug 23 '18 at 08:37

1 Answers1

0

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;
}
SHR
  • 7,940
  • 9
  • 38
  • 57
  • I think this error is related to this function in cst_val.c `void *val_void(const cst_val *v) { /* The scary, do anything function, this shouldn't be called by mortals */ if ((v == NULL) || (CST_VAL_TYPE(v) == CST_VAL_TYPE_CONS) || (CST_VAL_TYPE(v) == CST_VAL_TYPE_INT) || (CST_VAL_TYPE(v) == CST_VAL_TYPE_FLOAT)) { cst_errmsg("VAL: tried to access void in %d typed val\n", (v ? CST_VAL_TYPE(v) : -1)); cst_error(); return NULL; } else return CST_VAL_VOID(v); } ` – warriorforce Aug 24 '18 at 20:30