📄 tp_comp_0.cc
字号:
// read the first file in the list // if (fgets((char*)hyp_file, ISIP_MAX_STRING_LENGTH, fpout_list) == (char*)NULL) { fprintf(stdout, "Error : mismatch in the number of "); fprintf(stdout, "input mfcc files and output files.\n"); exit(ISIP_PROTO_ERROR); } // skip the newline // while (*hyp_file == ISIP_NEWLINE) { // make sure there is a corresponding output file for each input // file // if (fgets((char*)hyp_file, ISIP_MAX_STRING_LENGTH, fpout_list) == (char*)NULL) { fprintf(stdout, "Error : mismatch in the number of "); fprintf(stdout, "input mfcc files and output files.\n"); exit(ISIP_PROTO_ERROR); } } Decoder::expand_filename_cc(hyp_file); open_file_cc(fpo, hyp_file, (char_1*)"w"); // read the nbest output file in the list // if (fpnbo_list != NULL) { if (fgets((char*)nbest_out, ISIP_MAX_STRING_LENGTH, fpnbo_list) == (char*)NULL) { fprintf(stdout, "Error : mismatch in the number of "); fprintf(stdout, "input mfcc files and nbest output files.\n"); exit(ISIP_PROTO_ERROR); } // skip the newline // while (*nbest_out == ISIP_NEWLINE) { // make sure there is a corresponding output file for each input // file // if (fgets((char*)nbest_out, ISIP_MAX_STRING_LENGTH, fpnbo_list) == (char*)NULL) { fprintf(stdout, "Error : mismatch in the number of "); fprintf(stdout, "input mfcc files and nbest output files.\n"); exit(ISIP_PROTO_ERROR); } } Decoder::expand_filename_cc(nbest_out); open_file_cc(fpnbo, nbest_out, (char_1*)"w"); } // if this is model-level segment mode // if (segment_mode_d == TP_MODEL_SEGMENT_MODE) { // read the first model-level segment file from the file list // if (fgets((char*)model_seg_in, ISIP_MAX_STRING_LENGTH, fpms_list) == (char*)NULL) { fprintf(stdout, "Error : mismatch in the number of , "); fprintf(stdout, "input mfcc files and input model-level segment files.\n"); exit(ISIP_PROTO_ERROR); } // skip the newline // while (*model_seg_in == ISIP_NEWLINE) { // make sure there is a corresponding mfcc file for each file // if (fgets((char*)model_seg_in, ISIP_MAX_STRING_LENGTH, fpli_list) == (char*)NULL) { fprintf(stdout, "Error : mismatch in the number of , "); fprintf(stdout, "input mfcc files and input model-level segment files.\n"); exit(ISIP_PROTO_ERROR); } } Decoder::expand_filename_cc(model_seg_in); open_file_cc(fpmsi, model_seg_in, (char_1*)"r"); // read lattice into the decoder and close file // decoder_d->read_model_segment_cc(fpmsi); if (fpmsi != (FILE*)NULL) { fclose(fpmsi); } } // if this is lattice rescoring mode // if ((function_mode_d == TP_LATTICE_RESCORE_FUNCTION) || (function_mode_d == TP_LATTICE_LATTICE_FUNCTION) || (function_mode_d == TP_LATTICE_VERIFY_FUNCTION)) { // read the first lattice file from the file list // if (fgets((char*)lattice_in, ISIP_MAX_STRING_LENGTH, fpli_list) == (char*)NULL) { fprintf(stdout, "Error : mismatch in the number of , "); fprintf(stdout, "input mfcc files and input lattice files.\n"); exit(ISIP_PROTO_ERROR); } // skip the newline // while (*lattice_in == ISIP_NEWLINE) { // make sure there is a corresponding lattice file for each file // if (fgets((char*)lattice_in, ISIP_MAX_STRING_LENGTH, fpli_list) == (char*)NULL) { fprintf(stdout, "Error : mismatch in the number of , "); fprintf(stdout, "input mfcc files and input lattice files.\n"); exit(ISIP_PROTO_ERROR); } } Decoder::expand_filename_cc(lattice_in); open_file_cc(fpli, lattice_in, (char_1*)"r"); // read lattice into the decoder and close file // decoder_d->read_lattice_cc(fpli); if (fpli != (FILE*)NULL) { fclose(fpli); } } // if this is lattice generation mode // if ((function_mode_d == TP_LATTICE_GENERATE_FUNCTION) || (function_mode_d == TP_LATTICE_LATTICE_FUNCTION)) { // read the first file from the lattice file list // if (fgets((char*)lattice_out, ISIP_MAX_STRING_LENGTH, fplo_list) == (char*)NULL) { fprintf(stdout, "Error : mismatch in the number of , "); fprintf(stdout, "input mfcc files and output lattice files.\n"); exit(ISIP_PROTO_ERROR); } // skip the newline // while (*lattice_out == ISIP_NEWLINE) { // make sure there is a corresponding lattice file for each file // if (fgets((char*)lattice_out, ISIP_MAX_STRING_LENGTH, fplo_list) == (char*)NULL) { fprintf(stdout, "Error : mismatch in the number of , "); fprintf(stdout, "input mfcc files and output lattice files.\n"); exit(ISIP_PROTO_ERROR); } } Decoder::expand_filename_cc(lattice_out); open_file_cc(fplo, lattice_out, (char_1*)"w"); } // if this is force alignment mode convert transcription into lattice // format // if (function_mode_d == TP_FORCE_ALIGN_FUNCTION) { // read first transcription string from the transcription file // if (fgets((char*)transcription, ISIP_MAX_STRING_LENGTH, fpli_list) == (char*)NULL) { fprintf(stdout, "Error : mismatch in the number of , "); fprintf(stdout, "input mfcc files and reference transcriptions.\n"); exit(ISIP_PROTO_ERROR); } // skip the newline // while (*transcription == ISIP_NEWLINE) { // make sure there is a corresponding transcription string for // each file // if (fgets((char*)transcription, ISIP_MAX_STRING_LENGTH, fpli_list) == (char*)NULL) { fprintf(stdout, "Error : mismatch in the number of , "); fprintf(stdout, "input mfcc files and reference transcriptions.\n"); exit(ISIP_PROTO_ERROR); } } decoder_d->read_lattice_cc(transcription); } // perform viterbi search // decoder_d->decode_cc(fpi, fpo, fplo, fpnbo); // acumulate the overall decoding time // decoder_d->get_decode_time_cc(tmp_dec_time); decoder_d->get_frame_cc(tmp_frame); dec_time += tmp_dec_time; frame += tmp_frame; utterance++; // output cumulate decoding time information // assuming frame_duration = 10 msec // fprintf(stdout, "%ld) Processed total %ld frames, decoding time = %.1f seconds, %.2f xRT\n\n", utterance, frame, dec_time, dec_time*100/frame); fflush(stdout); // close the files // if (fpi != (FILE*)NULL) { fclose(fpi); } if (fpo != (FILE*)NULL) { fclose(fpo); } if (fplo != (FILE*)NULL) { fclose(fplo); } if (fpnbo != (FILE*)NULL) { fclose(fpnbo); } } // end while loop over all files // print the overall decoding time information // fprintf(stdout, "Finished decoding total %ld utterances:\n total %ld frames\n total decoding time = %.1f seconds, %.2f xRT\n", utterance, frame, dec_time, dec_time*100/frame); fflush(stdout); // close all files // if (fpin_list != (FILE*)NULL) { fclose(fpin_list); } if (fpout_list != (FILE*)NULL) { fclose(fpout_list); } if ((function_mode_d == TP_LATTICE_VERIFY_FUNCTION) || (function_mode_d == TP_LATTICE_RESCORE_FUNCTION) || (function_mode_d == TP_LATTICE_LATTICE_FUNCTION) || (function_mode_d == TP_FORCE_ALIGN_FUNCTION)) { if (fpli_list != (FILE*)NULL) { fclose(fpli_list); } } if ((function_mode_d == TP_LATTICE_VERIFY_FUNCTION) || (function_mode_d == TP_LATTICE_LATTICE_FUNCTION) || (function_mode_d == TP_LATTICE_GENERATE_FUNCTION)) { if (fplo_list != (FILE*)NULL) { fclose(fplo_list); } } if ((function_mode_d == TP_LATTICE_RESCORE_FUNCTION) || (function_mode_d == TP_NGRAM_DECODE_FUNCTION) || (function_mode_d == TP_LATTICE_VERIFY_FUNCTION)) { if (fpnbo_list != (FILE*)NULL) { fclose(fpnbo_list); } } // free memory // if (feat_file != (char_1*)NULL) { delete [] feat_file; feat_file = (char_1*)NULL; } if (hyp_file != (char_1*)NULL) { delete [] hyp_file; hyp_file = (char_1*)NULL; } if (lattice_in != (char_1*)NULL) { delete [] lattice_in; lattice_in = (char_1*)NULL; } if (lattice_out != (char_1*)NULL) { delete [] lattice_out; lattice_out = (char_1*)NULL; } if (transcription != (char_1*)NULL) { delete [] transcription; transcription = (char_1*)NULL; } if (nbest_out != (char_1*)NULL) { delete [] nbest_out; nbest_out = (char_1*)NULL; } if (model_seg_in != (char_1*)NULL) { delete [] model_seg_in; model_seg_in = (char_1*)NULL; } } // end else if not lattice error rate mode // exit gracefully // return ISIP_TRUE;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -