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

📄 slev_06.cc

📁 这是一个从音频信号里提取特征参量的程序
💻 CC
📖 第 1 页 / 共 4 页
字号:
  return dummy_symbol_table_d.write(sof_a, tag_a, PARAM_DUMMY_SYMBOL);}// method: loadExcludeSymbols//// arguments://  Sof& sof: (input) sof file object//  long tag: (input) sof object instance tag//// return: a boolean indicating status//// this method read the exclude symbol table from Sof file//boolean SearchLevel::loadExcludeSymbols(Sof& sof_a, long tag_a) {  // if no tag is specified, the tag should be this level number  //      if (tag_a == DEF_TAG) {    tag_a = (long)level_index_d;  }    // read the exclude symbol table if being present in the file  //    if (exclude_symbol_table_d.read(sof_a, tag_a, PARAM_EXCLUDE_SYMBOL)) {        // verify that the exclude symbols are a subset of all valid symbols    //    SearchSymbol symbol;    for (int i=0; i < exclude_symbol_table_d.length(); i++) {      symbol.assign(exclude_symbol_table_d(i));      if (!isValidSymbol(getSymbolIndex(symbol))) {	symbol.debug(L"invalid exclude symbol");	return Error::handle(name(), L"loadExcludeSymbols: there is a exclude symbol that does not appear in the symbol table", SearchLevel::ERR, __FILE__, __LINE__);	      }    }  }    // exit gracefully  //  return true;}// method: storeExcludeSymbols//// arguments://  Sof& sof: (input) sof file object//  long tag: (input) sof object instance tag//// return: a boolean indicating status//// this method writes the exclude symbol table from Sof file//boolean SearchLevel::storeExcludeSymbols(Sof& sof_a, long tag_a) {  // if no tag is specified, the tag should be this level number  //    if (tag_a == DEF_TAG) {    tag_a = (long)level_index_d;  }    // store the symbol table and exit  //  return exclude_symbol_table_d.write(sof_a, tag_a, PARAM_EXCLUDE_SYMBOL);}// method: loadLevelTag//// arguments://  Sof& sof: (input) sof file object//  long tag: (input) sof object instance tag//// return: a boolean indicating status//// this method read the symbol table from Sof file//boolean SearchLevel::loadLevelTag(Sof& sof_a, long tag_a) {  // if no tag is specified, the tag should be this level number  //      if (tag_a == DEF_TAG) {    tag_a = (long)level_index_d;  }    // load the level tag  //  level_tag_d.read(sof_a, tag_a, PARAM_LEVEL_TAG);  // exit gracefully  //  return true;}// method: storeLevelTag//// arguments://  Sof& sof: (input) sof file object//  long tag: (input) sof object instance tag//// return: a boolean indicating status//// this method writes the Skip symbol table from Sof file//boolean SearchLevel::storeLevelTag(Sof& sof_a, long tag_a) {  // if no tag is specified, the tag should be this level number  //    if (tag_a == DEF_TAG) {    tag_a = (long)level_index_d;  }    // store the symbol table and exit  //  return level_tag_d.write(sof_a, tag_a, PARAM_LEVEL_TAG);}// method: loadSymbols//// arguments://  Sof& sof: (input) sof file object//  long tag: (input) sof object instance tag//// return: a boolean indicating status//// this method read the symbol table from Sof file//boolean SearchLevel::loadSymbols(Sof& sof_a, long tag_a) {  // if no tag is specified, the tag should be this level number  //      if (tag_a == DEF_TAG) {    tag_a = (long)level_index_d;  }    // load the symbol table and exit  //  symbol_table_d.read(sof_a, tag_a, PARAM_SYMBOL);  // load the nsymbol model if applicable  //  if (use_nsymbol_d) {        // open the n-symbol model file    //    Sof tmp_file;    if (!tmp_file.open(nsymbol_file_d)) {      return Error::handle(name(), L"loadSymbols", Error::ARG, __FILE__, __LINE__);    }    // load the n-symbol model    //    if (!loadNSymbolModel(tmp_file, tag_a)) {      return Error::handle(name(), L"loadSymbols", Error::ARG, __FILE__, __LINE__);    }    tmp_file.close();  }  // exit gracefully  //  return true;}// method: loadNSymbolModel//// arguments://  long tag: (input) sof object instance tag//// return: a boolean indicating status//// this method read the nsymbol model from Sof file//boolean SearchLevel::loadNSymbolModel(long tag_a) {  // if no tag is specified, the tag should be this level number  //      if (tag_a == DEF_TAG) {    tag_a = (long)level_index_d;  }    // load the nsymbol model if applicable  //  if (use_nsymbol_d) {        // open the n-symbol model file    //    Sof tmp_file;    if (!tmp_file.open(nsymbol_file_d)) {      return Error::handle(name(), L"loadSymbols", Error::ARG, __FILE__, __LINE__);    }    // load the n-symbol model    //    if (!loadNSymbolModel(tmp_file, tag_a)) {      return Error::handle(name(), L"loadSymbols", Error::ARG, __FILE__, __LINE__);    }    tmp_file.close();  }  // exit gracefully  //  return true;}// method: storeSymbols//// arguments://  Sof& sof: (input) sof file object//  long tag: (input) sof object instance tag//// return: a boolean indicating status//// this method writes the symbol table from Sof file//boolean SearchLevel::storeSymbols(Sof& sof_a, long tag_a) {  // if no tag is specified, the tag should be this level number  //      if (tag_a == DEF_TAG) {    tag_a = (long)level_index_d;  }  // remove the NO_LEFT_CONTEXT and NO_RIGHT_CONTEXT symbols in case  // these symbols exist in the symbol-table  //  long j = 0;  long len = symbol_table_d.length();  Vector<SearchSymbol> symbol_table(len);    for( long i = 0; i < len; i++) {    if (!((symbol_table_d(i).eq(SearchSymbol::NO_LEFT_CONTEXT)) ||	(symbol_table_d(i).eq(SearchSymbol::NO_RIGHT_CONTEXT)))) {      symbol_table.setLength(j + 1);      symbol_table(j) = symbol_table_d(i);      j++;    }  }  symbol_table_d.assign(symbol_table);    // store the symbol table and exit  //  return symbol_table_d.write(sof_a, tag_a, PARAM_SYMBOL);}// method: loadNonSpeechSymbols//// arguments://  Sof& sof: (input) sof file object//  long tag: (input) sof object instance tag//// return: a boolean indicating status//// this method read the non-speechsymbol table from Sof file//boolean SearchLevel::loadNonSpeechSymbols(Sof& sof_a, long tag_a) {  // if no tag is specified, the tag should be this level number  //      if (tag_a == DEF_TAG) {    tag_a = (long)level_index_d;  }    // read the non-speech symbol table if being present in the file  //    if (nonspeech_symbol_table_d.read(sof_a, tag_a, PARAM_NONSPEECH_SYMBOL)) {        // verify that the non-speech symbols are a subset of all valid symbols    //    SearchSymbol symbol;    for (int i=0; i < nonspeech_symbol_table_d.length(); i++) {      symbol.assign(nonspeech_symbol_table_d(i));      if (!isValidSymbol(getSymbolIndex(symbol))) {	symbol.debug(L"invalid non-speech symbol");	return Error::handle(name(), L"loadNonSpeechSymbols: there is a non-speech symbols that does not appear in the symbol table", SearchLevel::ERR, __FILE__, __LINE__);	      }    }  }    // exit gracefully  //  return true;}// method: storeNonSpeechSymbols//// arguments://  Sof& sof: (input) sof file object//  long tag: (input) sof object instance tag//// return: a boolean indicating status//// this method writes the non-speech symbol table from Sof file//boolean SearchLevel::storeNonSpeechSymbols(Sof& sof_a, long tag_a) {  // if no tag is specified, the tag should be this level number  //    if (tag_a == DEF_TAG) {    tag_a = (long)level_index_d;  }    // store the symbol table and exit  //  return nonspeech_symbol_table_d.write(sof_a, tag_a, PARAM_NONSPEECH_SYMBOL);}// method: loadSubGraphs//// arguments://  Sof& sof: (input) sof file object//  long tag: (input) sof object instance tag//// return: a boolean indicating status//// this method has the object read itself from an Sof file//boolean SearchLevel::loadSubGraphs(Sof& sof_a, long tag_a) {  // make sure the symbol table has been loaded  //  long num_symbols = symbol_table_d.length();  long symbol_index = -1;    if (num_symbols == 0) {    return Error::handle(name(), L"loadSubGraphs - symbol table has not been loaded", SearchLevel::ERR, __FILE__, __LINE__);  }    // if no tag is specified, the tag should be its level number  //  if (tag_a == DEF_TAG) {    tag_a = (long)level_index_d;  }    // declare a temporary holder for the Graph<Ulong>  and read them from file  //   Vector< DiGraph<Ulong> > tmp_graphs;  if (!tmp_graphs.read(sof_a, tag_a, PARAM_MODEL)) {    return false;  }  // read statistical models if being present in file  //  boolean stat_model_flag = false;    if (stat_models_d.read(sof_a, tag_a, PARAM_STAT)) {    stat_model_flag = true;        // make sure the number of stat models is the same as that of symbols    //    if (stat_models_d.length() > num_symbols) {            return Error::handle(name(), L"loadSubGraphs - there are more statistical models than the search symbols", SearchLevel::ERR, __FILE__, __LINE__);    }  }    // variable for graphs conversion  //  long num_vertices;  GraphVertex<SearchNode>** snode_vert = (GraphVertex<SearchNode>**)NULL;  SearchNode** snode = (SearchNode**)NULL;    // set the number of sub graphs and allocation mode  //  long num_graphs = tmp_graphs.length();  setNumSubGraphs(num_graphs);  // convert each Graph<Ulong> to Graph<SearchNode> >  //  for (long k = 0; k < num_graphs; k++) {        // get the number of vertices from the input graph    //    num_vertices  = tmp_graphs(k).length() + 2;        // declare a graph of SearchNode and a local holder of those temporary    // GraphVertex<Ulong>    //    snode_vert = new GraphVertex<SearchNode>*[num_vertices];    snode = new SearchNode*[num_vertices];    GraphVertex<Ulong>* tmp_vert[num_vertices];        // set the properties of graphs    //    sub_graphs_d(k).setWeighted(tmp_graphs(k).isWeighted());    // index all the vertices so that they can be referenced easily    //    tmp_vert[0] = tmp_graphs(k).getStart();        // loop through the list of vertices and index them    //    tmp_graphs(k).gotoFirst();    for (long i = 1; i < num_vertices - 1; i++) {      tmp_vert[i] = const_cast<GraphVertex<Ulong>* >(tmp_graphs(k).getCurr());      tmp_graphs(k).gotoNext();    }        // the last vertex is the terminal node    //    tmp_vert[num_vertices - 1] = tmp_graphs(k).getTerm();    // create a list of SearchNode Vertices    // set the items properly    //    snode_vert[0] = sub_graphs_d(k).getStart();    snode_vert[num_vertices - 1] = sub_graphs_d(k).getTerm();        for (long i = 1; i < num_vertices - 1; i++) {      // set its item      //      Ulong* tmp_item = tmp_vert[i]->getItem();      snode[i] = new SearchNode();      snode[i]->setSearchLevel(this);      symbol_index = (long)(*tmp_item);      // check if this index is in the range of symbols      //      if (symbol_index < 0 || symbol_index >= num_symbols ) {	return Error::handle(name(), L"loadSubGraphs:: invalid symbol index",			     SearchLevel::ERR, __FILE__, __LINE__);      }      snode[i]->setSymbolId(symbol_index);      // if the statistical model is available, also set it      //      if (stat_model_flag) {	snode[i]->setModelId(symbol_index);    	snode[i]->setStatisticalModel(&stat_models_d(symbol_index));      }    }        // add the vertices to the graph    //    for (long i = 1; i < num_vertices - 1; i++) {      snode_vert[i] = sub_graphs_d(k).insertVertex(snode[i]);    }    // connect the vertices with arcs to complete the graph    //    for (long i = 0; i < num_vertices; i++) {      // get the vertex      //      GraphVertex<Ulong>* tmp_start_vert = tmp_vert[i];      // get the list of arcs for this vertex      //      boolean arcs_remain = tmp_start_vert->gotoFirst();      while (arcs_remain) {	// declare temporary arcs and vertices	//

⌨️ 快捷键说明

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