⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tp_comp_0.cc

📁 这是处理语音信号的程序
💻 CC
📖 第 1 页 / 共 2 页
字号:
// file: tp_comp_0.cc//// isip include files//#include "trace_projector.h"#include "trace_projector_constants.h"#include <time.h>// method: compute_cc//// arguments: none//// return: a logical flag to indicate success//logical_1 Trace_projector::compute_cc() {  // if this is lattice error rate mode, only need the lattice and  // transcription files  //  if (function_mode_d == TP_LATTICE_WER_FUNCTION) {    // read the lattice list file    //    if (lattice_file_d == (char_1*)NULL) {      fprintf(stdout, "Error: input lattice list file not specified\n");      exit(ISIP_PROTO_ERROR);    }        // open lattice file list    //    FILE* flat = (FILE*)NULL;    open_file_cc(flat, lattice_file_d, (char_1*)"r");    // read the utterance list file    //    if (forcealign_file_d == (char_1*)NULL) {      fprintf(stdout, "Error: forced alignment file not specified\n");      exit(ISIP_PROTO_ERROR);    }        // open transcription i.e. forced alignment file    //    FILE* fref = (FILE*)NULL;    open_file_cc(fref, forcealign_file_d, (char_1*)"r");        // open the output file    //    FILE* fout = (FILE*)NULL;    open_file_cc(fout, latwer_file_d, (char_1*)"w");    // compute the lattice wer    //    fprintf(stdout, "Computing lattice word error rates...\n");    decoder_d->lattice_wer_cc(flat, fref, fout);    // close files    //    if (flat != (FILE*)NULL) {      fclose(flat);    }    if (fref != (FILE*)NULL) {      fclose(fref);    }    if (fout != (FILE*)NULL) {      fclose(fout);    }  }  // otherwise this is decoding mode  //  else {      // load acoustic model related data into the decoder and clean    // related memory    //    fprintf(stdout, "Loading acoustic model data...\n");    load_ac_models_cc();        // if ngram required in the specified function mode, load the ngram    // language model    //    if ((function_mode_d == TP_NGRAM_DECODE_FUNCTION) ||	(function_mode_d == TP_LATTICE_GENERATE_FUNCTION) ||	(function_mode_d == TP_LATTICE_VERIFY_FUNCTION)) {            FILE* fp;      // check if the ngram lm file exists      //      if (lm_file_d == (char_1*)NULL) {	fprintf(stdout, "Error: language model file not specified\n");	exit(ISIP_PROTO_ERROR);      }      open_file_cc(fp, lm_file_d, (char_1*)"r");            // load the ngram      //      fprintf(stdout, "Reading language model data...\n");      decoder_d->read_ngram_cc(fp);      if (fp != (FILE*)NULL) {	fclose(fp);      }      // check if the list of grammars is specified      //      if (gram_list_file_d != (char_1*)NULL) {	// open file	//	open_file_cc(fp, gram_list_file_d, (char_1*)"r");	// load the grammars for hierarchical grammar processing	//	decoder_d->read_gram_list_cc(fp);	if (fp != (FILE*)NULL) {	  fclose(fp);	}      }    }    // set the user specified lm scaling and word insertion values      //    decoder_d->set_lmscale_cc(lm_scale_d);    decoder_d->set_wdpenalty_cc(word_penalty_d);        // set the acoustic context mode    //    decoder_d->set_context_mode_cc(context_mode_d);        // set the pruning related parameters and clean related memory     //    decoder_d->set_beams_cc(beam_width_d);    decoder_d->set_mapmi_limit_cc(mapmi_limit_d);    decoder_d->set_max_words_cc(num_wdcut_d);        // set the nbest pruning related parameters    //    decoder_d->set_nbest_maxpaths_cc(nbest_max_paths_d);    decoder_d->set_nbest_beam_cc(nbest_beam_d);    // initialize the decoder for hypothesizing utterances    //    decoder_d->init_cc();    // file pointers for processing lists of files    //    FILE* fpin_list = (FILE*)NULL;    FILE* fpout_list = (FILE*)NULL;    FILE* fpli_list = (FILE*)NULL;    FILE* fplo_list = (FILE*)NULL;    FILE* fpnbo_list = (FILE*)NULL;    FILE* fpms_list = (FILE*)NULL;        // open the file containing the list of input mfcc files    //    if (input_file_d == (char_1*)NULL) {      fprintf(stdout, "Error: input mfcc file list not specified\n");      exit(ISIP_PROTO_ERROR);    }    open_file_cc(fpin_list, input_file_d, (char_1*)"r");    // open the file containing the list of output files    //    if (output_file_d == (char_1*)NULL) {      fprintf(stdout, "Error: output file list not specified\n");      exit(ISIP_PROTO_ERROR);    }    open_file_cc(fpout_list, output_file_d, (char_1*)"r");    // open the file containing the list of model-level segment files    //    if (segment_mode_d == TP_MODEL_SEGMENT_MODE) {            // check if file exists      //      if (model_segment_file_d == (char_1*)NULL) {	fprintf(stdout, "Error: input model-level segment list file not specified\n");	exit(ISIP_PROTO_ERROR);      }            // open model-level segment file list      //      open_file_cc(fpms_list, model_segment_file_d, (char_1*)"r");    }        // open the file containing the list of lattice files    //    if ((function_mode_d == TP_LATTICE_RESCORE_FUNCTION) ||	(function_mode_d == TP_LATTICE_LATTICE_FUNCTION) ||	(function_mode_d == TP_LATTICE_VERIFY_FUNCTION)) {            // check if file exists      //      if (lattice_file_d == (char_1*)NULL) {	fprintf(stdout, "Error: input lattice list file not specified\n");	exit(ISIP_PROTO_ERROR);      }            // open lattice file list      //      open_file_cc(fpli_list, lattice_file_d, (char_1*)"r");    }    // if this is lattice generate mode there is a list of output    // lattices    //    if ((function_mode_d == TP_LATTICE_GENERATE_FUNCTION) ||	(function_mode_d == TP_LATTICE_LATTICE_FUNCTION)) {            // check if file exists      //      if (outlat_file_d == (char_1*)NULL) {	fprintf(stdout, "Error: output lattice list file not specified\n");	exit(ISIP_PROTO_ERROR);      }            // open lattice file      //      open_file_cc(fplo_list, outlat_file_d, (char_1*)"r");    }    // open the output nbest list file    //    if (((function_mode_d == TP_LATTICE_RESCORE_FUNCTION) ||	 (function_mode_d == TP_NGRAM_DECODE_FUNCTION) ||	 (function_mode_d == TP_LATTICE_VERIFY_FUNCTION)) &&	(num_nbest_d > 1)) {            // check if file exists      //      if (outnbest_file_d == (char_1*)NULL) {	fprintf(stdout, "Error: output nbest list file not specified\n");	exit(ISIP_PROTO_ERROR);      }            // open lattice file      //      open_file_cc(fpnbo_list, outnbest_file_d, (char_1*)"r");    }        // open the file containing reference transcriptions for forced    // alignment    //    if (function_mode_d == TP_FORCE_ALIGN_FUNCTION) {            // check if file exists      //      if (forcealign_file_d == (char_1*)NULL) {	fprintf(stdout, "Error: forced alignment file not specified\n");	exit(ISIP_PROTO_ERROR);      }            // open forced alignment file      //      open_file_cc(fpli_list, forcealign_file_d, (char_1*)"r");    }    // define file pointers for data files    //    FILE* fpi = (FILE*)NULL;    FILE* fpo = (FILE*)NULL;    FILE* fpli = (FILE*)NULL;    FILE* fplo = (FILE*)NULL;    FILE* fpnbo = (FILE*)NULL;    FILE* fpmsi = (FILE*)NULL;        // allocate memory for individual mfcc, lattice and output files    //    char_1* feat_file = new char_1[ISIP_MAX_STRING_LENGTH];    char_1* hyp_file = new char_1[ISIP_MAX_STRING_LENGTH];    char_1* lattice_in = new char_1[ISIP_MAX_STRING_LENGTH];    char_1* lattice_out = new char_1[ISIP_MAX_STRING_LENGTH];    char_1* transcription = new char_1[ISIP_MAX_STRING_LENGTH];    char_1* nbest_out = new char_1[ISIP_MAX_STRING_LENGTH];    char_1* model_seg_in = new char_1[ISIP_MAX_STRING_LENGTH];    // timiming information variable    //    float_8 dec_time = 0, tmp_dec_time;    int_4 frame = 0, utterance = 0, tmp_frame;    int_4 num_file = 1;        // read the corresoponding data file from each list and process one    // by one    //    while (fgets((char*)feat_file, ISIP_MAX_STRING_LENGTH, fpin_list) !=	   (char*)NULL) {      // skip the new line      //          while (*feat_file == ISIP_NEWLINE) {	while (fgets((char*)feat_file, ISIP_MAX_STRING_LENGTH, fpin_list) !=	       (char*)NULL);	  }            // expand the input filename      //      Decoder::expand_filename_cc(feat_file);      if (input_format_d == TP_ASCII_FORMAT) {	open_file_cc(fpi, feat_file, (char_1*)"r");      }      else {	open_file_cc(fpi, feat_file, (char_1*)"rb");      }            // print status message      //      fprintf(stdout, "processing file %ld: %s\n", num_file, feat_file);      fflush(stdout);      num_file++;      

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -