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

📄 bw_train.cc

📁 这是处理语音信号的程序
💻 CC
📖 第 1 页 / 共 2 页
字号:
	  memset(lower, 0, (num_vect+1)*sizeof(int_2));	  memset(upper, 0, (num_vect+1)*sizeof(int_2));	  	  // initialize the probabilities array	  //	  utt_prob = BW_LOG_ZERO;	  max_back = new float_8[num_vect+1];	  max_mback = new float_8*[num_vect+1];	  back_prob = new float_8**[num_vect+1];	  state_scores = new float_8**[num_vect+1];	  // loop over all the time frames	  //	  for (int_4 i = 0; i < num_vect; i++) {	    lower[i+1] = 1;	    upper[i+1] = num_mod;	    back_prob[i+1] = new float_8*[num_mod+1];	    state_scores[i+1] = new float_8*[num_mod+1];	    max_mback[i+1] = new float_8[num_mod+1];	    // loop over all the models in the	    // current utterance	    //	    for (int_4 j = 0; j < num_mod; j++) {	      temp_st = models[model_list[j]]->get_num_states_cc();	      back_prob[i+1][j+1] = new float_8[temp_st+1];	      state_scores[i+1][j+1] = new float_8[temp_st+1];	      max_mback[i+1][j+1] = BW_LOG_ZERO;	      // loop over all the states in the	      // current model	      //	      for (int_4 k = 0; k < temp_st; k++) {		back_prob[i+1][j+1][k+1] = BW_LOG_ZERO;		state_scores[i+1][j+1][k+1] = BW_LOG_ZERO;	      }	    }	    max_back[i+1] = BW_LOG_ZERO;	  }	  	  for_probt = new float_8*[num_mod+1];	  for_probt1 = new float_8*[num_mod+1];	  for (int_4 i = 0; i < num_mod; i++) {	    temp_st = models[model_list[i]]->get_num_states_cc();	    for_probt[i+1] = new float_8[temp_st+1];	    for_probt1[i+1] = new float_8[temp_st+1];	    for (int_4 j = 0; j < temp_st; j++) {	      for_probt[i+1][j+1] = BW_LOG_ZERO;	      for_probt1[i+1][j+1] = BW_LOG_ZERO;	    }	  }	  // initialize the state-frames for the relevant models	  //	  for (int_4 i = 0; i < num_mod; i++) {	    temp_st = models[model_list[i]]->get_num_states_cc();	    for (int_4 j = 0; j < temp_st; j++) {	      states[st_map[model_list[i]][j]]->set_frame_cc((int_4)-1);	    }	  }	  	  // compute the upper bound and lower bound for each state of input	  // phone sequence	  //	  get_bound_cc(upper, lower, num_vect, models, num_mod, model_list);	  // compute the forward and backward probability for each	  // state if they are applicable	  //	  if (comp_back_prob_cc(back_prob, utt_prob, max_back, max_mback,				upper, lower, width, num_vect, transitions,				states, num_mod, model_list, models,				trans_map, vectors, st_map, num_phy_st,				state_scores)	      == ISIP_TRUE) {	    	    // accumulate the utterance probability	    //	    utt_avg += utt_prob;	    cur_prob = utt_prob/num_vect;	    num_utt += num_vect;	    fprintf(stdout, "utterance probability: %f\n", cur_prob);	    fflush(stdout);	    	    // loop over every frame to compute forward probabilities	    // and update transitions and state pdfs	    //	    for (int_4 frame = 1; frame <= num_vect; frame++) {	      	      if (comp_for_prob_cc(for_probt, for_probt1, back_prob, upper,				   lower, frame, transitions, states, num_mod,				   model_list, models, trans_map, vectors,				   st_map, max_back, max_mback, width,				   utt_prob, state_scores, min_mpd)		== ISIP_TRUE) {				// update the transition accumulator for current utterance		//		acc_trans_cc(new_trans, for_probt, back_prob,			     transitions, states, models, num_mod,			     model_list, trans_map, st_map, num_vect,			     vectors, utt_prob, state_scores, frame,			     upper, lower);				// update the state accumulator for current utterance		//		acc_pdf_cc(train_mean, train_covar, mix_weights, state_occ,			   vectors, num_features, num_vect, num_mod,			   model_list, st_map, states, models, utt_prob,			   for_probt, for_probt1, back_prob, frame,			   upper, lower, min_mpd, min_occp);		// change the forward probabilities for next frame		//		for (int_4 i = 0; i < num_mod; i++) {		  temp_st = models[model_list[i]]->get_num_states_cc();		  for (int_4 j = 0; j < temp_st; j++) {		    for_probt1[i+1][j+1] = for_probt[i+1][j+1];		    for_probt[i+1][j+1] = BW_LOG_ZERO;		  }		}	      } // end if we can compute forward probability properly	      else {		break;	      }	    }	  } // end if we can compute backward probability properly	  // clean up	  //	  for (int_4 i = 0; i < num_vect; i++) {	    delete [] vectors[i]; vectors[i] = (float_8*)NULL;	  }	  delete [] vectors; vectors = (float_8**)NULL;	  	  delete [] lower;	  delete [] upper;	  	  for (int_4 i = 1; i < num_vect+1; i++) {	    for (int_4 j = 1; j < num_mod+1; j++) {	      delete [] back_prob[i][j];	      delete [] state_scores[i][j];	    }	    delete [] back_prob[i];	    delete [] state_scores[i];	    delete [] max_mback[i];	  }	  for (int_4 i = 1; i < num_mod+1; i++) {	    delete [] for_probt[i];	    delete [] for_probt1[i];	  }	  delete [] for_probt;	  delete [] for_probt1;	  delete [] back_prob;	  delete [] state_scores;	  delete [] max_back;	  delete [] max_mback;	  delete [] model_list;	}      } // end if mfcc file is valid    }        // close file handles    //    fclose(fml);    fclose(fll);  }  // print out accumulators if in batch processing mode  //  if (train_mode == BW_BATCH_MODE) {    // print out all accumulators based on input train data    //    print_acc_cc(fp_acc_file, new_trans, num_trans, trans_size,		 train_mean, train_covar, mix_weights, state_occ, num_states,		 num_mix, num_features, model_access_counts, num_models);    // clean up    //    fclose(fp_acc_file);  }  else {    // update the pdf parameters    //    update_pdf_cc(states, train_mean, train_covar, mix_weights, state_occ,		  num_states, num_features, var_floor, models,		  model_access_counts, num_models, min_model_count);        // output the new transition matrix    //    print_trans_cc(new_trans_file, num_trans, trans_size, new_trans,		   transitions, models, model_access_counts, num_models,		   min_model_count);        // output the new states data    //    print_states_cc(new_states_file, states, num_states, num_features,		    output_mode);        // print out all the state occupancy    //    if (occ_mode == BW_OPT_ON) {      print_occ_cc(state_occ_file, states, phones, num_phones,		   num_states, state_occ);    }  }    if (train_mode != BW_COMBINE_MODE) {              // update the utterance score    //    if (num_utt != 0) {      utt_avg /= num_utt;      fflush(stdout);      fprintf(stdout, "Average score per frame: %f\n", utt_avg);    }  }    // clean up  //  delete [] mod_map;  delete [] trans_map;  delete [] phone_map;  for (int_4 i = 0; i < num_trans; i++) {    for (int_4 j = 0; j < trans_size[i]; j++) {      delete [] transitions[i][j];      delete [] new_trans[i][j];    }    delete [] transitions[i];    delete [] new_trans[i];  }  delete [] transitions;   delete [] new_trans;   delete [] trans_size;     for (int_4 i = 0; i < num_models; i++) {    delete models[i];    delete [] st_map[i];  }  delete [] models;   delete [] st_map;    for (int_4 i = 0; i < num_phones; i++) {    delete phones[i];  }  delete [] phones;    for (int_4 i = 0; i < num_monophones; i++) {    delete [] monophones[i];  }  delete [] monophones;     for (int_4 i = 0; i < num_states; i++) {    for (int_4 j =0; j < num_mix; j++) {      delete [] train_mean[i][j];      delete [] train_covar[i][j];    }    delete [] train_mean[i];    delete [] train_covar[i];    delete [] mix_weights[i];    delete states[i];  }  delete [] train_mean;   delete [] train_covar;  delete [] mix_weights;  delete [] state_occ;  delete [] states;  delete [] var_floor;  delete [] model_access_counts;    delete [] params_file;  delete [] monophones_file;  delete [] transitions_file;  delete [] states_file;  delete [] new_trans_file;  delete [] new_states_file;  delete [] models_file;  delete [] phones_file;  delete [] mfcclist_file;  delete [] mfcc_file;  delete [] lablist_file;  delete [] output_file;  delete [] acc_file;  delete [] acclist_file;  delete [] state_occ_file;  delete [] lab_file;  delete [] var_floor_file;    // exit gracefully  //  exit(ISIP_NO_ERROR);}

⌨️ 快捷键说明

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