cst_voice* register_cmu_us_no_wave( const char* voxdir ) { 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 ) ); cmu_us_no_wave = v; return cmu_us_no_wave; }
cst_voice *register_cmu_us_kal16(const char *voxdir) { cst_voice *v = new_voice(); usenglish_init(v); /* Set up basic values for synthesizing with this voice */ feat_set_string(v->features,"name","cmu_us_kal_diphone"); /* Lexicon */ cmu_lex_init(); feat_set(v->features,"lexicon",lexicon_val(&cmu_lex)); /* Intonation */ feat_set_float(v->features,"int_f0_target_mean",105.0); feat_set_float(v->features,"int_f0_target_stddev",14.0); /* Post lexical rules */ feat_set(v->features,"postlex_func",uttfunc_val(&cmu_us_kal_postlex)); /* Duration */ feat_set_float(v->features,"duration_stretch",1.1); /* Waveform synthesis: diphone_synth */ feat_set(v->features,"wave_synth_func",uttfunc_val(&diphone_synth)); feat_set(v->features,"diphone_db",diphone_db_val(&cmu_us_kal_db)); feat_set_int(v->features,"sample_rate",cmu_us_kal_db.sts->sample_rate); feat_set_string(v->features,"resynth_type","fixed"); feat_set_string(v->features,"join_type","modified_lpc"); cmu_us_kal_diphone = v; return cmu_us_kal_diphone; }
static void ef_set(cst_features *f,const char *fv,const char *type) { /* set feature from fv (F=V), guesses type if not explicit type given */ const char *val; char *feat; if ((val = strchr(fv,'=')) == 0) { fprintf(stderr, "flite: can't find '=' in featval \"%s\", ignoring it\n", fv); } else { feat = cst_strdup(fv); feat[strlen(fv)-strlen(val)] = '\0'; val = val+1; if ((type && cst_streq("int",type)) || ((type == 0) && (cst_regex_match(cst_rx_int,val)))) feat_set_int(f,feat,atoi(val)); else if ((type && cst_streq("float",type)) || ((type == 0) && (cst_regex_match(cst_rx_double,val)))) feat_set_float(f,feat,atof(val)); else feat_set_string(f,feat,val); /* I don't free feat, because feats think featnames are const */ /* which is true except in this particular case */ } }
static void ef_set(cst_features *f,const char *fv,const char *type) { /* set feature from fv (F=V), guesses type if not explicit type given */ const char *val; char *feat; if ((val = strchr(fv,'=')) == 0) { fprintf(stderr, "flite: can't find '=' in featval \"%s\", ignoring it\n", fv); } else { feat = cst_strdup(fv); feat[cst_strlen(fv)-cst_strlen(val)] = '\0'; val = val+1; if ((type && cst_streq("int",type)) || ((type == 0) && (cst_regex_match(cst_rx_int,val)))) feat_set_int(f,feat,atoi(val)); else if ((type && cst_streq("float",type)) || ((type == 0) && (cst_regex_match(cst_rx_double,val)))) feat_set_float(f,feat,atof(val)); else feat_set_string(f,feat,val); cst_free(feat); } }
static void flite_set_pitch(signed int pitch) { float f0; assert(pitch >= OTTS_VOICE_PITCH_MIN && pitch <= OTTS_VOICE_PITCH_MAX); f0 = (((float)pitch) * 0.8) + 100.0; feat_set_float(flite_voice->features, "int_f0_target_mean", f0); }
cst_val *cst_args(char **argv, int argc, const char *description, cst_features *args) { /* parses the given arguments wrt the description */ cst_features *op_types = new_features(); cst_val *files = NULL; int i; const char *type; parse_description(description,op_types); for (i=1; i<argc; i++) { if (argv[i][0] == '-') { if ((!feat_present(op_types,argv[i])) || (cst_streq("-h",argv[i])) || (cst_streq("-?",argv[i])) || (cst_streq("--help",argv[i])) || (cst_streq("-help",argv[i]))) parse_usage(argv[0],"","",description); else { type = feat_string(op_types,argv[i]); if (cst_streq("<binary>",type)) feat_set_string(args,argv[i],"true"); else { if (i+1 == argc) parse_usage(argv[0], "missing argument for ",argv[i], description); if (cst_streq("<int>",type)) feat_set_int(args,argv[i],atoi(argv[i+1])); else if (cst_streq("<float>",type)) feat_set_float(args,argv[i],atof(argv[i+1])); else if (cst_streq("<string>",type)) feat_set_string(args,argv[i],argv[i+1]); else parse_usage(argv[0], "unknown arg type ",type, description); i++; } } } else files = cons_val(string_val(argv[i]),files); } delete_features(op_types); return val_reverse(files); }
cst_voice *register_cmu_us_kal16(const char *voxdir) { cst_voice *v; cst_lexicon *lex; if (cmu_us_kal16_diphone) return cmu_us_kal16_diphone; /* Already registered */ v = new_voice(); v->name = "kal16"; /* Sets up language specific parameters in the cmu_us_kal16. */ usenglish_init(v); feat_set_string(v->features,"name","cmu_us_kal16"); 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); /* Lexicon */ lex = cmu_lex_init(); feat_set(v->features,"lexicon",lexicon_val(lex)); feat_set(v->features,"postlex_func",uttfunc_val(lex->postlex)); /* Waveform synthesis */ feat_set(v->features,"wave_synth_func",uttfunc_val(&diphone_synth)); feat_set(v->features,"diphone_db",diphone_db_val(&cmu_us_kal16_db)); feat_set_int(v->features,"sample_rate",cmu_us_kal16_db.sts->sample_rate); /* feat_set_string(v->features,"join_type","simple_join"); */ feat_set_string(v->features,"join_type","modified_lpc"); feat_set_string(v->features,"resynth_type","fixed"); cmu_us_kal16_diphone = v; return cmu_us_kal16_diphone; }
static void flite_set_rate(signed int rate) { const float stretch_default = 1., stretch_min = 3., stretch_max = (1 - 100. / 175.); float stretch; assert(rate >= OTTS_VOICE_RATE_MIN && rate <= OTTS_VOICE_RATE_MAX); if (rate < OTTS_VOICE_RATE_DEFAULT) stretch = stretch_min + ((float)(rate - OTTS_VOICE_RATE_MIN)) * (stretch_default - stretch_min) / ((float)(OTTS_VOICE_RATE_DEFAULT - OTTS_VOICE_RATE_MIN)); else stretch = stretch_default + (((float)(rate - OTTS_VOICE_RATE_DEFAULT)) * (stretch_max - stretch_default) / ((float) (OTTS_VOICE_RATE_MAX - OTTS_VOICE_RATE_DEFAULT))); feat_set_float(flite_voice->features, "duration_stretch", stretch); }
void item_set_float(const cst_item *i,const char *name,float val) { feat_set_float(item_feats(i),name,val); }
void flite_feat_set_float(cst_features *f, const char *name, float v) { feat_set_float(f,name,v); }