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

📄 lm_10.cc

📁 这是一个从音频信号里提取特征参量的程序
💻 CC
字号:
// file: $isip/class/asr/LanguageModel/lm_10.cc// version: $Id: lm_10.cc,v 1.3 2002/04/10 20:19:24 yuan Exp $//// isip include files//#include "LanguageModel.h"#include <Console.h>// method: setGraphEndings//// arguments: Sof& sof_a: (input) a sof file containing grammars//// return: a boolean value indicating status//boolean LanguageModel::setGraphEndings(Sof& sof_a) {  // declare a tag for searching in the sof file  //  String tag = L"JSGF";  String algo_line, head_line, JSGF_line;  // find the tag  //  if(!sof_a.find(tag, 100)) {    return Error::handle(tag, L"no matching tag", Error::TEST,			 __FILE__, __LINE__);  }  // read the first algorithm name  //  sof_a.gets(algo_line, Sof::BUFFER_SIZE);  // check the alogotithm name  //  if(algo_line.eq(L"algorithm = \"JSGF\";", true)) {    // get the two JSGF grammars    //    for(long i=0; i<2; i++) {      // take off the grammar head line "grammar = {" and      // move the sof pointer to the beginning line of grammar      //      sof_a.gets(head_line, Sof::BUFFER_SIZE);          // read the first line of JSGF grammar      //      sof_a.gets(JSGF_line, Sof::BUFFER_SIZE);      // go on reading the following lines      //      while(!JSGF_line.eq(L"};", true)) {	// get the postion of the first character in the line	//	long start = JSGF_line.firstNotSpace(0);		// check if the first six letters is a keyword "public"	// which indicates a public rule	//	String sub_str;	long pos = start + 6;	String delim(L" ;");	JSGF_line.substr(sub_str, start, 6);	if(sub_str.eq(L"public", true)) {  	  String rulename, symbol;	  // get the rulename	  //	  JSGF_line.tokenize(rulename, pos, delim);	  // if the rule is for the graph starting point	  //	  if(rulename.eq(L"<ISIP_JSGF_1_0_START>", true)) {	    // get the symbol and set it as class protected graph_symbol_d	    //	    while(JSGF_line.tokenize(symbol, pos, delim)) {	      graph_start_d.assign(symbol);	    }	  }	  // if the rule is for the graph terminal point	  //	  else if(rulename.eq(L"<ISIP_JSGF_1_0_TERM>", true)) {	    	    // get the symbol and set it as class protected graph_term_d	    //	    while(JSGF_line.tokenize(symbol, pos, delim)) {	      graph_term_d.assign(symbol);	    }	  }	  else {	     return Error::handle(rulename, L"no matching rules defined",			 Error::TEST, __FILE__, __LINE__);	  }	} // end of if(sub_str.eq(L"public", true))		// read next line	//	sof_a.gets(JSGF_line, Sof::BUFFER_SIZE);	      } // end of while(!JSGF_line.eq(L"};", true)    } // end of for(long i=0; i<2; i++)  } // end of if(algo_line.eq(L"algorithm = \"JSGF\";", true))  else {    return Error::handle(algo_line, L"no matching algorithm defined",			 Error::TEST, __FILE__, __LINE__);  }  // gracefully exit  //  return true;}// method: isNonSpeechDefinition//// arguments: String& arg_a: (input) a JSGF grammar string//// return: a boolean value indicating status//// check if the input grammar string is a definition for the ISIP// reserved nonspeech symbols//boolean LanguageModel::isNonSpeechDefinition(String& arg_a) {  String sub, input(arg_a), delim(L" \n");  long pos = 0;  // search "public" keyword  //  while(input.tokenize(sub, pos, delim)) {    if(sub.eq(L"public")) {      // check the next token      //      input.tokenize(sub, pos, delim);            if(sub.eq(L"<ISIP_NON_SPEECH>")) {	return true;      }    }  }  // the definition not found  //  return false;}

⌨️ 快捷键说明

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