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

📄 isip_transform.cc

📁 这是一个从音频信号里提取特征参量的程序
💻 CC
字号:
// file: $isip/util/speech/isip_transform/isip_transform.cc// version: $Id: isip_transform.cc,v 1.29 2002/10/17 19:31:56 gao Exp $//// isip include files//#include "isip_transform.h"// utility: isip_transform: //// this is a general data transformation utility. it can be used for// feature extraction, feature translation, or audio conversions.//int main(int argc, const char** argv) {  //---------------------------------------------------------------------------  //  // section 1: initialize command line processing  //  //---------------------------------------------------------------------------  // configure the command line parser and an Sdb object.  //  Sdb sdb;  CommandLine cmdl(sdb);    cmdl.setUsage(#include "usage_message.text"                );  cmdl.setHelp(#include "help_message.text"               );    cmdl.setIdent("$Revision: 1.29 $",		"$Name: isip_r00_n11 $",		"$Date: 2002/10/17 19:31:56 $");    // add a command line option for output type  //  String output_type;  cmdl.addOptionParam(output_type, OPTION_OUTPUT_TYPE, EMPTY);  // add a command line option for suffix  //  String output_suffix;  cmdl.addOptionParam(output_suffix, OPTION_OUTPUT_SUFFIX, EMPTY);        // add a command line option for the parameter file  //  Filename param_file;  cmdl.addOptionParam(param_file, OPTION_PARAMS_FILE, (Filename)EMPTY);    // add a command line option for the debug level  //  DebugLevel debug_level;  cmdl.addOptionParam(debug_level, OPTION_DEBUG_LEVEL);    // add a command line option for the verbosity  //  DebugLevel verbosity;  cmdl.addOptionParam(verbosity, OPTION_VERBOSITY_LEVEL);    // add a command line option for the log file  //  Filename log_file;  cmdl.addOptionParam(log_file, OPTION_LOG_FILE, (Filename)LOG_FILE_DEFAULT);    // parse the command line  //  cmdl.parse(argc,argv);  // define a local variable to remember if the extension defined in the  // command line, default false mean users do not define in cmdl  //  boolean extension_exist = false;      // check if new_extension option in the command line users provided  //  // get actual command line  //  String arg;  cmdl.getActualCmdl(arg);  // declare local variables  //  long pos = 0;  long cmdl_len = arg.length();  String token;  String output_extension;    // call tokenize method if length is greater than zero  //  if (cmdl_len > 0) {    // call tokenize method and check if there is extension option    //    while (arg.tokenize(token, pos)) {        if (token.firstStr(CommandLine::DEF_PARAM_PREFIX) == 0) {        // declare a string to hold the default new extension option        //	String new_extension(CommandLine::DEF_PARAM_PREFIX);	new_extension.concat(CommandLine::DEF_PARAM_EXTENSION);	// compare with the cmdl option	if (token.eq( new_extension)) {	  arg.tokenize(token,pos);	  output_extension = token;	  extension_exist=true;	}      }    } // end of while  }  // end of if    // print the command line  //  if (verbosity >= Integral::BRIEF) {    cmdl.printCommandLine();    cmdl.printVersion();  }  // check the param file argument  //  if(param_file.eq((Filename)EMPTY)) {    cmdl.printUsage();  };  // loop over all input files  //  if (!sdb.gotoFirst()) {    // add default output file to the doubleLinkedList    //    sdb.append(DEF_FILE_NAME);  }  // default behavior of the console class should be not to wrap lines  //  Console::setLineWrap(File::NO_WRAP);    // open the log file  //  if (log_file.ne(L"-")) {    Console::open(log_file);  }  // building parameter files list if users provide  //  Sdb sdb_params;  // check if the recipe file exists  //  if (!File::exists(param_file)) {    String msg(L"Error: could not find parameter file: ");    msg.concat(param_file);    Console::put(msg);    cmdl.printUsage();  }    // check if the recipe file is a file list or just a recipe file  //  if (Sdb::isSdb(param_file)) {    sdb_params.append(param_file, true);  }  else {    sdb_params.append(param_file);  }    //---------------------------------------------------------------------------  //  // section 2: load all recipes and create a vector of front ends  //  //---------------------------------------------------------------------------  // define some local variables  //  long len = 0;  Sof param_sof;  Vector<String> vector_param;    // goto first param file  //  if (!sdb_params.gotoFirst()) {    String msg(L"Error: could not get parameter file: ");    Console::put(msg);    cmdl.printUsage();  }  // loop over all param files to get the number of recipe files  // and the vector to hold the files  //  do {    sdb_params.getName(param_file);    vector_param.concat(param_file);    // increment the number of parameter files    //    len++;  } while (sdb_params.gotoNext());  // increase the indention  //  Console::increaseIndention();    if (verbosity >= Integral::BRIEF) {    String output(L"\n");    Console::putNoWrap(output);  }  if (verbosity >= Integral::BRIEF) {    String output;    output.assign(L"       total ");    output.concat(len);    output.concat(L" recipe files");    Console::putNoWrap(output);  }    Vector <FrontEnd> vector_fe;   vector_fe.setLength(len);  // goto first param file  //  if (!sdb_params.gotoFirst()) {    String msg(L"Error: could not get parameter file: ");    Console::put(msg);    cmdl.printUsage();  }    for (long num_param = 0; num_param < len; num_param++) {        // get the param file    //    sdb_params.getName(param_file);          // read the configuration of the FrontEnd from the parameter file    //    long tag = 0;    if (!param_sof.open(param_file)) {      String msg(L"Error: could not open parameter file: ");      msg.concat(param_file);      Console::put(msg);      cmdl.printUsage();      Error::handle(PROG_NAME, L"main", Error::NO_PARAM_FILE,		    __FILE__, __LINE__);    }        if (((tag = param_sof.first(FrontEnd::name())) == Sof::NO_TAG) ||	(!vector_fe(num_param).read(param_sof, tag))) {	      String msg(L"Error: could not read configuration from file: ");      msg.concat(param_file);      Console::put(msg);      cmdl.printUsage();      Error::handle(PROG_NAME, L"main", Error::NO_PARAM_FILE,		    __FILE__, __LINE__);	    }    param_sof.close();        // set the front-end's debug level and verbosity    //    vector_fe(num_param).setDebug(debug_level);    vector_fe(num_param).setVerbosity(verbosity);    if (extension_exist)      vector_fe(num_param).setOutputExtension(output_extension);    if (output_type.length() > 0) {      if (output_type.eq(L"TEXT", false)) {	File::TYPE temp_type = File::TEXT;	vector_fe(num_param).setOutputType(temp_type);      }      else if (output_type.eq(L"BINARY", false)) {	File::TYPE temp_type = File::BINARY;	vector_fe(num_param).setOutputType(temp_type);      }      else	cmdl.printUsage();    }    sdb_params.gotoNext();  }      //---------------------------------------------------------------------------  //  // section 3: main processing loop  //  //---------------------------------------------------------------------------  // we will need input and output files  //  Filename input_file;  Filename output_file;    // count the number of files processed  //  long num_files = 0;  long num_processed = 0;  long num_params = 0;  long num_params_processed = 0;    // loop from start  //  if (!sdb.gotoFirst()) {    String msg(L"Error: no input file specified ");    Console::put(msg);    Error::handle(PROG_NAME, L"main", Error::NO_PARAM_FILE,		  __FILE__, __LINE__);  }  long len_input = 0;  // loop over all input speech files to get the number of speech  // files needed to process  //  do {    // increment the number of input speech files    //    len_input++;  } while (sdb.gotoNext());  if (verbosity >= Integral::BRIEF) {    String output;    output.assign(L"       total ");    output.concat(len_input);    output.concat(L" input files");    Console::putNoWrap(output);  }  // loop from start  //  if (!sdb.gotoFirst()) {    String msg(L"Error: no input file specified ");    Console::put(msg);    Error::handle(PROG_NAME, L"main", Error::NO_PARAM_FILE,		  __FILE__, __LINE__);  }    // loop over all input file  //  do {    sdb.getName(input_file);    // incremement the number of files read    //    num_files++;        // loop over all params files    //    num_params = 0;    num_params_processed = 0;    if (verbosity >= Integral::BRIEF) {      String output(L"\n");      Console::putNoWrap(output);    }        for (long j = 0; j < len; j++) {      // increment the number of parameter files processing      //      num_params++;      if (verbosity >= Integral::BRIEF) {	String output(L"     processing params file: ");	output.concat(num_params);	output.concat(L": ");	output.concat(vector_param(j));	Console::putNoWrap(output);      }      Filename temp_input(input_file);            // adding suffix if users specified      //      if (output_suffix.length() > 0) {	temp_input.transformSuffix(output_suffix);      }            if (((output_suffix.length() > 0) &&	   sdb.transformName(output_file, temp_input) ||	   (output_suffix.length() == 0) &&	   !sdb.transformName(output_file, temp_input)) &&	  (vector_fe(j).getInputFlag())) {	String msg(L"Error: please specify source file in commandline ");	Console::put(msg);	cmdl.printUsage();	Error::handle(PROG_NAME, L"main", Error::NO_PARAM_FILE,		      __FILE__, __LINE__);            }      // process the data      //      if (vector_fe(j).run(output_file, input_file)) {	// increment the number of params files successfully processed	//	num_params_processed++;      }          }    // report on the number of files processed    //    if (verbosity >= Integral::BRIEF) {      String output(L"processing file ");      output.concat(num_files);      output.concat(L": ");      output.concat(input_file);      output.concat(L"---> ");      String str;      output_file.getBase(str);      str.deleteRange(str.lastChr(L'.'), -1);      str.concat(L".*");      output.concat(str);      Console::putNoWrap(output);      String report(PROG_NAME);      report.concat(L": processed ");      report.concat(num_params_processed);      report.concat(L" parameters file(s), attempd ");      report.concat(num_params);      report.concat(L" file(s)");      Console::putNoWrap(report);    }        // increment the number of files successfully processed    //    num_processed++;      } while (sdb.gotoNext());    // decrease the indention  //  Console::decreaseIndention();    //---------------------------------------------------------------------------  //  // section 4: summarization  //  //---------------------------------------------------------------------------  // report on the number of files processed  //  cmdl.printFinalReport(num_processed, num_files);    // close the log file  //  if (log_file.ne(L"-")) {    Console::close();  }    // exit gracefully  //  Integral::exit();}

⌨️ 快捷键说明

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