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

📄 hsrch_09.cc

📁 这是一个从音频信号里提取特征参量的程序
💻 CC
📖 第 1 页 / 共 2 页
字号:
// file: $isip/class/search/HierarchicalSearch/hsrch_09.cc// version: $Id: hsrch_09.cc,v 1.33 2003/03/27 05:03:16 alphonso Exp $//// isip include files//#include "HierarchicalSearch.h"// method: grammarDecoder//// arguments://  FrontEnd& fe: (input) front-end for extracting features//  long num_frames: (input) the number of steps to move forward//// return: logical error status//// decode part (or all) of the search space - one pass grammar decoder//boolean HierarchicalSearch::grammarDecoder(FrontEnd& fe_a, long num_frames_a) {  // if we haven't started the search then we need to initialize the search  //  if ((long)current_frame_d == DEF_START_FRAME) {    initializeGrammarDecoder();  }  // determine the number of frames to loop through. If the user specifies  // to loop over all frames then the frame_num is set to a default value  // so that the decoder loops indefinitely  //  long frame_num = 0;  if (num_frames_a == DEF_NUM_FRAMES) {    frame_num = num_frames_a - 1;  }    // loop over the specified number of frames  //  while (fe_a.getVector(features_d, 0, current_frame_d) &&	 frame_num < num_frames_a) {    // decode one frame of data    //    if (!traverseInstanceLevels()) {      break;    }    // increment the frame_num if necessary - otherwise we loop indefinitely    //    if (num_frames_a != DEF_NUM_FRAMES) {      frame_num++;    }  }  // exit gracefully  //  return true;  }// method: grammarDecoder//// arguments://  Vector<VectorFloat>& fe: (input) vector of inputs//  long num_frames: (input) the number of steps to move forward//// return: logical error status//// decode part (or all) of the search space - one pass grammar decoder//boolean HierarchicalSearch::grammarDecoder(Vector<VectorFloat>& fe_a,					long num_frames_a) {  Error::handle(name(), L"not implemented", Error::ARG, __FILE__, __LINE__);      // exit gracefully  //  return true;  }// method: linearDecoder//// arguments://  FrontEnd& fe: (input) front-end for extracting features//  long num_frames: (input) the number of steps to move forward//// return: logical error status//// decode part (or all) of the search space//boolean HierarchicalSearch::linearDecoder(FrontEnd& fe_a, long num_frames_a) {  // if we haven't started the search then we need to initialize the  // search  //  if ((long)current_frame_d == DEF_START_FRAME) {    initializeLinearDecoder();  }  // determine the number of frames to loop through. If the user specifies  // to loop over all frames then the frame_num is set to a default value  // so that the decoder loops indefinitely  //  long frame_num = 0;  if (num_frames_a == DEF_NUM_FRAMES) {    frame_num = num_frames_a - 1;  }    // loop over the specified number of frames  // ISIP_BUG: (hamaker) the channel is set to zero here which won't be  //           right for multi-channel data  //  while (fe_a.getVector(features_d, 0, current_frame_d) &&	 frame_num < num_frames_a) {    // ISIP_BUG: check the feature length here    // decode one frame of data    //    if (!traverseTraceLevels()) {      break;    }    // increment the frame_num if necessary - otherwise we loop indefinitely    //    if (num_frames_a != DEF_NUM_FRAMES) {      frame_num++;    }  }  // exit gracefully  //  return true;}// method: linearDecoder//// arguments://  Vector<VectorFloat>& fe: (input) vector of inputs//  long num_frames: (input) the number of steps to move forward//// return: logical error status//// decode part (or all) of the search space//boolean HierarchicalSearch::linearDecoder(Vector<VectorFloat>& fe_a,				   long num_frames_a) {  // if we haven't started the search then we need to initialize the  // search  //  if ((long)current_frame_d == DEF_START_FRAME) {    initializeLinearDecoder();  }  // determine the number of frames to loop through. If the user specifies  // to loop over all frames then the frame_num is set to a default value  // so that the decoder loops indefinitely  //  long frame_num = 0;  if (num_frames_a == DEF_NUM_FRAMES) {    frame_num = num_frames_a - 1;  }    // loop over the specified number of frames  //  long size = fe_a.length();    while (current_frame_d < size &&	 features_d.assign(fe_a(current_frame_d)) &&	 frame_num < num_frames_a) {    // decode one frame of data    //    if (!traverseTraceLevels()) {      break;    }        // increment the frame_num if necessary - otherwise we loop indefinitely    //    if (num_frames_a != DEF_NUM_FRAMES) {      frame_num++;    }  }    // exit gracefully  //  return true;}// method: initializeContextGeneration//// arguments: none//// return: logical error status//// initialize the context generation setup//boolean HierarchicalSearch::initializeContextGeneration() {  // make sure that context does not exist for the transcription level  //  if (search_levels_d((long)initial_level_d).useContext()) {    return Error::handle(name(), L"initializeContextGeneration - context can not be defined for the transcription level", Error::ARG, __FILE__, __LINE__);  }  // set the context mode flag  //  context_generation_mode_d = true;    // set the capacity of the hash tables and symbol tables  //  long num_symbols =    search_levels_d((long)context_level_d).getSymbolTable().length();  long num_left_context =    search_levels_d((long)context_level_d).getLeftContext();  long num_right_context =    search_levels_d((long)context_level_d).getRightContext();    long capacity = (long)Integral::pow((double)num_symbols, (num_left_context + num_right_context + 1));    context_list_d.setCapacity(capacity);  context_hash_d.setCapacity(capacity);    // exit gracefully  //  return true;}// method: initializeGrammarPartial//// arguments: none//// return: logical error status//// initialize the hypothesis path containers and forward-backward structures//boolean HierarchicalSearch::initializeGrammarPartial() {  // make sure that we have at least one level defined  //  long num_levels = getNumLevels();    if (num_levels < 1) {    return Error::handle(name(), L"initializeGrammarPartial", Error::ARG, __FILE__, __LINE__);  }  // make sure that context does not exist for the acoustic level  //  if (search_levels_d(num_levels - 1).useContext()) {    return Error::handle(name(), L"initializeGrammarPartial - context can not be defined for the acoustic level", Error::ARG, __FILE__, __LINE__);  }    // clear the instance hypothesis list  //  clearInstanceStorage();    // clear the instance lists of all the search nodes  //  clearSearchNodesInstanceLists();           // clear the history pool  //  if (history_pool_d.length() > 0) {    history_pool_d.clear(Integral::RETAIN);  }  // clear the context pool  //  if (context_pool_d.length() > 0) {    context_pool_d.clear(Integral::RETAIN);  }  // clear the trellis before starting  //    if (search_mode_d == TRAIN) {    trellis_d.clear();  }  // set the current frame  //  current_frame_d = 0;    // exit gracefully  //  return true;}// method: initializeGrammarDecoder//// arguments: none//// return: logical error status//// initialize the lists, etc. needed to begin searching//boolean HierarchicalSearch::initializeGrammarDecoder() {  // initialize the hypothesis path containers and forward-backward structures  //  initializeGrammarPartial();  // error checking  //  if (getSearchLevel(initial_level_d).getRightContext() !=      getSearchLevel(initial_level_d).getLeftContext()) {    return Error::handle(name(), L"initializeGrammarDecoder - left and right context lengths must be the same", Error::ARG, __FILE__, __LINE__);  }    // get the position of the central item in the context  //  long central_pos =    getSearchLevel(initial_level_d).getRightContext() + 1;  long left_context_length =    getSearchLevel(initial_level_d).getLeftContext();    long total_context_length = left_context_length + central_pos;    // initialize the context length  //  Context left_context(total_context_length, central_pos);    for (long i = 0; i < central_pos; i++) {    left_context.assignAndAdvance((ulong)search_levels_d((long)initial_level_d).getSubGraph(0).getStart());  }    // output the debugging information  //  if (debug_level_d >= Integral::ALL) {    left_context.print();  }    // generate list of all possible right contexts  //  Context* symbol = context_pool_d.get(left_context);  long depth = search_levels_d((long)initial_level_d).getRightContext();  if (!initializeRightContexts((Instance*)NULL, *symbol, 0, 0.0, depth)) {    return Error::handle(name(), L"propagateInstancesDown", Error::ARG, __FILE__, __LINE__);  }    // exit gracefully  //  return true;}// method: initializeLinearPartial//// arguments: none//// return: logical error status//// initialize the hypothesis path containers and forward-backward structures//boolean HierarchicalSearch::initializeLinearPartial() {  // make sure that we have at least one level defined  //  if ( getNumLevels() < 1) {    return Error::handle(name(), L"initializeLinearPartial", Error::ARG, __FILE__, __LINE__);  }    // clear the trace hypothesis list  //  clearTraceStorage();    // clear the trace lists of all the search nodes  //  clearSearchNodesTraceLists();  // clear the history pool  //  if (history_pool_d.length() > 0) {    history_pool_d.clear(Integral::RETAIN);  }    // clear the context pool  //  if (context_pool_d.length() > 0) {    context_pool_d.clear(Integral::RETAIN);  }    // clear the trellis before starting  //  if (search_mode_d == TRAIN) {    trellis_d.clear();  }  // set the current frame  //  current_frame_d = 0;    // exit gracefully  //  return true;  }// method: initializeLinearDecoder//// arguments: none//

⌨️ 快捷键说明

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