int main(int argc, char* argv[]) { size_t num_voices; char **fn_voices; char* in_fname; char* output_fname; FILE * outfp; char* dur_fname; FILE * durfp; bool print_label = false; bool print_utt = false; bool write_raw = false; bool write_durlabel = false; CFSAString LexFileName, LexDFileName; HTS_Engine engine; double speed = 1.1; size_t fr = 48000; size_t fp = 240; float alpha = 0.55; float beta = 0.0; float ht = 2.0; float th = 0.5; float gvw1 = 1.0; float gvw2 = 1.2; FSCInit(); fn_voices = (char **) malloc(argc * sizeof (char *)); if (argc < 11) { fprintf(stderr, "Viga: liiga vähe parameetreid\n\n"); PrintUsage(); } for (int i = 0; i < argc; i++) { if (CFSAString("-lex") == argv[i]) { if (i + 1 < argc) { LexFileName = argv[++i]; } else { return PrintUsage(); } } if (CFSAString("-lexd") == argv[i]) { if (i + 1 < argc) { LexDFileName = argv[++i]; } else { return PrintUsage(); } } if (CFSAString("-m") == argv[i]) { if (i + 1 < argc) { fn_voices[0] = argv[i + 1]; } else { fprintf(stderr, "Viga: puudub *.htsvoice fail\n"); PrintUsage(); exit(0); } } if (CFSAString("-o") == argv[i]) { if (i + 1 < argc) { output_fname = argv[i + 1]; cfileexists(output_fname); } else { fprintf(stderr, "Viga: puudb väljundfaili nimi\n"); PrintUsage(); exit(0); } } if (CFSAString("-f") == argv[i]) { if (i + 1 < argc) { in_fname = argv[i + 1]; } else { fprintf(stderr, "Viga: puudb sisendfaili nimi\n"); PrintUsage(); exit(0); } } if (CFSAString("-s") == argv[i]) { if (i + 1 < argc) { samplerate(fr, fp, alpha, atoi(argv[i + 1])); } } if (CFSAString("-r") == argv[i]) { if (i + 1 < argc) { speed = atof(argv[i + 1]); } } if (CFSAString("-ht") == argv[i]) { if (i + 1 < argc) { ht = atof(argv[i + 1]); } } if (CFSAString("-gvw1") == argv[i]) { if (i + 1 < argc) { gvw1 = atof(argv[i + 1]); } } if (CFSAString("-gvw2") == argv[i]) { if (i + 1 < argc) { gvw2 = atof(argv[i + 1]); } } if (CFSAString("-debug") == argv[i]) { print_label = true; } if (CFSAString("-utt") == argv[i]) { print_utt = true; } if (CFSAString("-raw") == argv[i]) { write_raw = true; } if (CFSAString("-dur") == argv[i]) { if (i + 1 < argc) { dur_fname = argv[i + 1]; cfileexists(dur_fname); write_durlabel = true; } else { fprintf(stderr, "Viga: puudb kestustefaili nimi\n"); PrintUsage(); exit(0); } } } Linguistic.Open(LexFileName); Disambiguator.Open(LexDFileName); CFSWString text; ReadUTF8Text(text, in_fname); HTS_Engine_initialize(&engine); if (HTS_Engine_load(&engine, fn_voices, 1) != TRUE) { fprintf(stderr, "Viga: puudub *.htsvoice. %p\n", fn_voices[0]); free(fn_voices); HTS_Engine_clear(&engine); exit(1); } free(fn_voices); HTS_Engine_set_sampling_frequency(&engine, (size_t) fr); HTS_Engine_set_phoneme_alignment_flag(&engine, FALSE); HTS_Engine_set_fperiod(&engine, (size_t) fp); HTS_Engine_set_alpha(&engine, alpha); HTS_Engine_set_beta(&engine, beta); HTS_Engine_set_speed(&engine, speed); HTS_Engine_add_half_tone(&engine, ht); HTS_Engine_set_msd_threshold(&engine, 1, th); /* HTS_Engine_set_duration_interpolation_weight(&engine, 1, diw); HTS_Engine_set_parameter_interpolation_weight(&engine, 0, 0, piw1); HTS_Engine_set_parameter_interpolation_weight(&engine, 0, 1, piw2); HTS_Engine_set_gv_interpolation_weight(&engine, 0, 0, giw1); HTS_Engine_set_gv_interpolation_weight(&engine, 0, 1, giw2); */ HTS_Engine_set_gv_weight(&engine, 0, gvw1); HTS_Engine_set_gv_weight(&engine, 1, gvw2); text = DealWithText(text); CFSArray<CFSWString> res = do_utterances(text); INTPTR data_size = 0; outfp = fopen(output_fname, "wb"); if (write_durlabel) durfp = fopen(dur_fname, "w"); if (!write_raw) HTS_Engine_write_header(&engine, outfp, 1); for (INTPTR i = 0; i < res.GetSize(); i++) { CFSArray<CFSWString> label = do_all(res[i], print_label, print_utt); std::vector<std::string> v; v = to_vector(label); std::vector<char*> vc; fill_char_vector(v, vc); size_t n_lines = vc.size(); if (HTS_Engine_synthesize_from_strings(&engine, &vc[0], n_lines) != TRUE) { fprintf(stderr, "Viga: süntees ebaonnestus.\n"); HTS_Engine_clear(&engine); exit(1); } clean_char_vector(vc); data_size += HTS_Engine_engine_speech_size(&engine); if (write_durlabel) HTS_Engine_save_durlabel(&engine, durfp); HTS_Engine_save_generated_speech(&engine, outfp); HTS_Engine_refresh(&engine); } //synth loop if (!write_raw) HTS_Engine_write_header(&engine, outfp, data_size); if (write_durlabel) fclose(durfp); fclose(outfp); HTS_Engine_clear(&engine); Linguistic.Close(); FSCTerminate(); return 0; }
int main() { char chout='\n'; int action=1; time_t last_time_action, current_time, last_time; if ( init_mpc () == 0) { printf("Error init mpc\n"); exit (-1); } output_t * output_st = init_output_st (); while (init_display(output_st)) { printf("Error display\n"); sleep (1); } set_cirilic (); clear_scr(); int encoder_fd = 0; if (cfileexists(ENCODER_COM_PORT)) { encoder_fd = init_comport(ENCODER_COM_PORT, ENCODER_COM_SPEED); } else { encoder_fd = init_comport(DEFAULT_ENCODER_COM_PORT, ENCODER_COM_SPEED); } init_term(); last_time = time(NULL); int count_click = 0; struct timeval t_start, t_end; int show_time = 0; while (1) { get_all (output_st); int ret_read = read_com(encoder_fd, 1 , 100, &chout); if ((chout=='R') || (chout=='L') ||(chout=='a') || (chout=='d')) { action=0; last_time_action = time(NULL); set_play_list_position(tuning_movement(chout)); get_cur_position (); show_current_cursor_pos (); } if ((chout=='P') ||(chout=='s') ) { gettimeofday(&t_end, NULL); if(!count_click) { t_start = t_end; count_click++; } else { if (usec_used (&t_start, &t_end) <= 500000) { double_click_button(); if (show_time) { show_time--; } else { show_time++; } } count_click = 0; } } if (count_click) { gettimeofday(&t_end, NULL); if (usec_used (&t_start, &t_end) > 500000) { print_button_pressed(); music_pause(); count_click = 0; } } chout = '\0'; current_time = time(NULL); if (action==0) { if ((current_time-last_time_action)>3) { action++; } } if ((action) && ((current_time-last_time)>0)) { if (!show_time) { show_current_track(output_st); } else { show_current_time_and_date(); } last_time = current_time; } } }