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

📄 isip_make_sof.cc

📁 这是一个从音频信号里提取特征参量的程序
💻 CC
字号:
// file: $isip/util/speech/isip_make_sof/isip_make_sof.cc// version: $Id: isip_make_sof.cc,v 1.6 2002/10/17 19:32:02 gao Exp $//// isip include files//#include "isip_make_sof.h"// isip_make_sof: data transformation utility//// this is the general data transformation utility. it can be used for// feature extraction, feature translation, or audio conversions.//int main(int argc, const char** argv) {  // 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.6 $",		"$Name: isip_r00_n11 $",		"$Date: 2002/10/17 19:32:02 $");		   // add a command line option for output type  //  String output_type;  cmdl.addOptionParam(output_type, PARAM_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 encoding  //  String encoding_str;  cmdl.addOptionParam(encoding_str, PARAM_ENCODING,	      (String&)AudioFile::COMP_TYPE_MAP((long)AudioFile::LINEAR));  // add a command line option for sample frequency  //  Float sample_freq;  cmdl.addOptionParam(sample_freq, PARAM_SF, AudioFile::DEF_SAMPLE_FREQ);  // add a command line option for byte order  //  String byte_order_str;  cmdl.addOptionParam(byte_order_str, PARAM_BYTE_ORDER,	      (String&)AudioFile::BMODE_MAP((long)AudioFile::NATIVE));  // add a command line option for the debug level  //  DebugLevel debug_level;  cmdl.addOptionParam(debug_level);  // add a command line option for the verbosity  //  DebugLevel verbosity;  cmdl.addOptionParam(verbosity, PARAM_VERBOSE);    // 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();  }    // obtain the encoding and byte_order from the strings  //  long val = AudioFile::COMP_TYPE_MAP(encoding_str);  if (val < 0) {    String msg(L"invalid encoding\n");    Console::put(msg);    AudioFile::COMP_TYPE_MAP.displayChoices(encoding_str);    cmdl.printUsage();    Error::handle(PROG_NAME, L"main", Error::ARG, __FILE__, __LINE__);  }  AudioFile::COMP_TYPE encoding = (AudioFile::COMP_TYPE)val;  val = AudioFile::BMODE_MAP(byte_order_str);  if (val < 0) {    String msg(L"invalid byte mode\n");    AudioFile::BMODE_MAP.displayChoices(byte_order_str);    Console::put(msg);    cmdl.printUsage();    Error::handle(PROG_NAME, L"main", Error::ARG, __FILE__, __LINE__);  }  AudioFile::BMODE byte_order = (AudioFile::BMODE)val;    // set up the front-end  //  AudioFrontEnd fe;  // read the configuration from the parameter file  //  Sof sof;  sof.open(FE_PARAM_FILE);  fe.read(sof, 0);  sof.close();    // configure all the input audio parameters for the front-end  //  fe.getAudioInput().setSampleFrequency(sample_freq);  fe.getAudioInput().setBMode(byte_order);  fe.getAudioInput().setCompType(encoding);  fe.getAudioInput().setFileFormat(AudioFile::RAW);  // configure output file type using command line option  //  if (output_type.length() > 0) {    if (output_type.eq(L"TEXT", false)) {      File::TYPE temp_type = File::TEXT;      fe.setOutputType(temp_type);    }    else if (output_type.eq(L"BINARY", false)) {      File::TYPE temp_type = File::BINARY;      fe.setOutputType(temp_type);    }    else      cmdl.printUsage();  }  // set the front-end's debug level and verbosity  //  fe.setDebug(debug_level);  fe.setVerbosity(verbosity);  // set the new extension if users specified  //  if (extension_exist)    fe.setOutputExtension(output_extension);    // loop over all input files  //  if (!sdb.gotoFirst()) {    cmdl.printUsage();    Error::handle(PROG_NAME, L"main", Error::NO_INPUT_FILE,		  __FILE__, __LINE__);  }  // 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;  // increase the indention  //  Console::increaseIndention();    do {    // determine the input and output filenames from Sdb    //    sdb.getName(input_file);    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)) &&	(fe.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__);          }        // incremement the number of files read    //    num_files++;    if (verbosity >= Integral::BRIEF) {      String output(L"processing file ");      output.concat(num_files);      output.concat(L": ");      output.concat(input_file);      Console::putNoWrap(output);    }        // process the data    //    if (fe.run(output_file, input_file)) {      // increment the number of files successfully processed      //      num_processed++;    }      } while (sdb.gotoNext());  // decrease the indention  //  Console::decreaseIndention();    // report on the number of files processed  //  cmdl.printFinalReport(num_processed, num_files);  // exit gracefully  //  Integral::exit();}

⌨️ 快捷键说明

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