コード例 #1
0
cst_voice *register___VOICENAME__(const char *voxdir)
{
    cst_voice *v = new_voice();

    v->name = "__NICKNAME__";

    /* Sets up language specific parameters in the __VOICENAME__. */
    usenglish_init(v);

    /* Things that weren't filled in already. */
    feat_set_string(v->features,"name","__VOICENAME__");

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

    /* Waveform synthesis */
    feat_set(v->features,"wave_synth_func",uttfunc_val(&clunits_synth));
    feat_set(v->features,"clunit_db",clunit_db_val(&__VOICENAME___db));
    feat_set_int(v->features,"sample_rate",__VOICENAME___db.sts->sample_rate);
    feat_set_string(v->features,"join_type","simple_join");
    feat_set_string(v->features,"resynth_type","fixed");

    /* Unit selection */
    __VOICENAME___db.unit_name_func = __VOICENAME___unit_name;

    __VOICENAME___clunits = v;

    return __VOICENAME___clunits;
}
コード例 #2
0
ファイル: cmu_us_kal16.c プロジェクト: deardaniel/PizzaTest
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;
}
コード例 #3
0
ファイル: flite_main.c プロジェクト: ljmljz/MMDAgent
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);
    }
}
コード例 #4
0
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          */
    }
}
コード例 #5
0
ファイル: cst_args.c プロジェクト: 2php/flite-2.0.0-release
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);
}
コード例 #6
0
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;
}
コード例 #7
0
int flowm_say_file(TCHAR *tfilename)
{
    int rc = 0;
    char *filename;
    cst_voice *v;
    
    if (previous_wave)
    {   /* This is really tidy up from Play -- but might say space */
        delete_wave(previous_wave);
        previous_wave = NULL;
    }

    if (fl_ad)
    {
        MessageBoxW(0,L"audio fd still open",L"SayFile",0);
        audio_close(fl_ad); 
        fl_ad = NULL;
    }

    v = VoxDefs[flowm_selected_voice].v;

    /* Where we want to start from */
    feat_set_int(v->features, "file_start_position", flowm_file_pos);

    /* Only do print_info in play mode */
    feat_remove(v->features,"print_info_relation");

    filename = cst_wstr2cstr(tfilename);
    rc = flite_file_to_speech(filename, v, "stream");
    cst_free(filename);

    audio_flush(fl_ad);
    audio_close(fl_ad); 
    fl_ad = NULL;

    return rc;

}
コード例 #8
0
void item_set_int(const cst_item *i,const char *name,int val)
{
    feat_set_int(item_feats(i),name,val);
}
コード例 #9
0
ファイル: flite.c プロジェクト: nlphacker/OpenSpeech
void flite_feat_set_int(cst_features *f, const char *name, int v)
{
    feat_set_int(f,name,v);
}
コード例 #10
0
int main(int argc, char **argv)
{
    bard_reader *br;
    cst_features *args;
    cst_features *config;
    float idle_time;
    int spos;

    args = new_features();
    cst_args(argv,argc,
	     "usage: bard OPTIONS\n"
             "Bard Storyteller\n"
             "-text <string> Text filename to read\n"
             "-text_pos <int> Starting position in text file\n"
             "-config_file <string> Override default config file ($HOME/.bard_config)\n"
             "-font <string> Pathname to ttf font file\n"
             "-font_size <int> Initial font size\n"
             "-audio_method <string> SDL or flite\n"
             "-voice <string> Voice name (or pathname to dumped voice)\n"
             "-audio_stream_buffer_factor  <int> Bigger for slower processors\n"
             "-gain <float> Volume factor (1.0 is default)\n"
             "-speed <float> Duration stretch (inverse speed)\n"
             "-battery_script <string> Script to get battery charge state\n"
             "-screen_height <int> \n"
             "-screen_width <int> \n"
             "-screen_blank_idle_time <float> In secs (0 means no blanking)\n"
             "-scroll_delay <int> In ms\n"
             "-voices_dir <string>  Directory containing *.flitevox voices\n"
             "-debug <int> Print debug messages\n"
             "",
             args);

    /* If text specified and no position given, start from 0 */
    if (feat_present(args,"-text") && !feat_present(args,"-text_pos"))
        feat_set_int(args,"-text_pos",0);
    if (!feat_present(args,"-font"))
        feat_set_string(args,"-font",BARD_DEFAULT_FONT);
    bard_debug = get_param_int(args,"-debug",0);

    config = bard_read_config(args);
    
    cst_feat_print(stdout,config);

    br = bard_open(config);
    if (br == NULL) return -1;  /* something went really wrong */

    /* Make the windows */
    br->text = bard_make_text_window(br);
    br->file_select = bard_make_file_select_window(br);
    br->info = bard_make_info_window(br); /* general info/params */
    br->help = bard_make_help_window(br);
    br->recent = bard_make_recent_window(br);
    br->menu = bard_make_menu_window(br);
    if (feat_present(br->config,"-voices_dir"))
        br->voice_select = bard_make_voice_select_window(br);
    /* Select focus */
    br->display->current = br->text;

    bard_display_clear(br->display);
    bard_display_update(br->display);
    bard_screen_on(NULL); /* just in case it is currently off */

    while (br->quit == 0)
    {
        if (input_process_events(br) == 0)
        {
            if (br->scroll)
            {
                SDL_Delay(br->scroll_delay); /* no key press but scrolling */
                br->quiet_time = SDL_GetTicks(); /* no blank while scrolling */
            }
            else
                SDL_Delay(br->no_key_delay); /* no key press, so pause a bit */
        }

        if (br->speak == 1)
        {
            /* Within the audio callback function, we also call */
            /* input_process_events so we can stop if requested */
            br->pause = 0;
            if (br->display->current->current_token)
                spos = br->display->current->current_token->file_pos;
            else
                spos = br->display->current->sop_pos;
            /* We need spos-1 here to make it display well */
            bard_speak_text(br->speech,br->display->current->textfile,spos-1);
                            
            br->speak = 0;
            br->quiet_time = SDL_GetTicks();
        }
        else if (br->scroll)
        {   /* Speaking and smooth scrolling are mutually exclusive */
            if (bard_text_scroll(br->text) == 0)
                br->scroll = 0;  /* Reached end of file so stop scroll */
            bard_display_update(br->display); /* Update screen */
        }
        else
            br->text->scroll_offset = 0;

        /* Check if we should black/hide cursor */
        idle_time = (SDL_GetTicks()-br->quiet_time)/1000.0;
        if ((br->screen_blank_idle_time > 0) &&
            (idle_time > br->screen_blank_idle_time) && 
            (br->blank == 0))
        {
            br->blank = 1;
            bard_screen_off(NULL);
        }
        idle_time = (SDL_GetTicks()-br->mouse_quiet_time)/1000.0;
        if (idle_time > 5.0)
            SDL_ShowCursor(SDL_DISABLE);
    }

    /* Save context */
    bard_write_config(br);

    bard_close(br);
    delete_features(args);

    return 0;
}