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

📄 trans_05.cc

📁 这是一个从音频信号里提取特征参量的程序
💻 CC
📖 第 1 页 / 共 2 页
字号:
// file: $isip/class/mmedia/TranscriptionDatabase/trans_05.cc// version: $Id: trans_05.cc,v 1.16 2003/05/06 15:02:50 alphonso Exp $//// isip include files//#include "TranscriptionDatabase.h"// method: assign//// arguments://  const TranscriptionDatabase& arg: (input) transDB object//// return: logical error status//// this method has assigns the input transcription database//boolean TranscriptionDatabase::assign(const TranscriptionDatabase& arg_a) {  // declare local variables  //  boolean status = false;  // determine if the TranscriptionDatabase objects are equal  //  status = name_d.assign(arg_a.name_d);  status &= hash_index_d.assign(arg_a.hash_index_d);  // return the status  //  return status;}// method: sofSize//// arguments: none//// return: logical error status//// this method determines the size of the object//long TranscriptionDatabase::sofSize() const {  // declare local variables  //  long size = 0;  // get the size of the object  //  size = name_d.sofSize();  size += hash_index_d.sofSize();  // return the size  //  return size;}// method: eq//// arguments://  const TranscriptionDatabase& arg: (input) transDB object//// return: logical error status//// this method has determines if the transcription databases are equal//boolean TranscriptionDatabase::eq(const TranscriptionDatabase& arg_a) const {    // declare local variables  //  boolean status = false;  // determine if the TranscriptionDatabase objects are equal  //  status = name_d.eq(arg_a.name_d);  status &= hash_index_d.eq(arg_a.hash_index_d);  // return the status  //  return status;}// method: clear//// arguments://  Integral::CMODE cmode: (input) clear mode//// return: logical error status//// this method clears the content of the current object//boolean TranscriptionDatabase::clear(Integral::CMODE cmode_a) {  // declare local variables  //  boolean status = false;    // clear the data members  //  status = name_d.clear(cmode_a);  status &= hash_d.clear(cmode_a);    status &= hash_index_d.clear(cmode_a);    // return the status  //  return status;}// method: insertRecord//// arguments://  String& identifier: (input) annotation graph id//  AnnotationGraph& graph: (input) desired annotation graph//// return: logical error status//// this method inserts the record into the database//boolean TranscriptionDatabase::insertRecord(String& identifier_a,					    AnnotationGraph& graph_a) {  // make sure the name of the graph matches the database name  //  if (!graph_a.getId().eq(name_d)) {    return Error::handle(name(), L"insertRecord", Error::ARG, __FILE__, __LINE__);  }  Long values;  // get the keys associated with the hash table  //  Vector<String> keys;  if (!hash_d.keys(keys)) {    return Error::handle(name(), L"insertRecord", Error::ARG, __FILE__, __LINE__);  }    values.assign(keys.length());    hash_index_d.insert(identifier_a, &values);    // insert the record into the database  //  return hash_d.insert(identifier_a, &graph_a);}// method: getRecord//// arguments://  String& identifier: (input) annotation graph id//  AnnotationGraph& graph: (output) desired annotation graph//// return: logical error status//// this method retrieves the record from the database//boolean TranscriptionDatabase::getRecord(String& identifier_a,					 AnnotationGraph& graph_a) {  // declare local variables  //  Long* tag;    // determine if the identifier exists in the database  //  tag = hash_index_d.get(identifier_a);  if (tag == (Long*)NULL) {    return false;  }    // when the identifier exists in the database return a copy of the record  //  else {    graph_a.clear();    if (!graph_a.read(database_sof_d, (long)*tag)) {      Error::handle(name(), L"getReord", Error::NO_PARAM_FILE,		    __FILE__, __LINE__);          }  }  // exit gracefully  //  return true;}// method: getRecord//// arguments://  String& identifier: (input) annotation graph id//  String& feature: (input) annotation feature//  String& value: (input) annotation feature value//  DoubleLinkedList<String>& records: (output) list of records//// return: logical error status//// this method retrieves the record from the database//boolean TranscriptionDatabase::getRecord(String& identifier_a,					 String& feature_a, String& value_a,					 DoubleLinkedList<String>& records_a) {  // declare local variables  //  String tmpstr;  DoubleLinkedList<Annotation> annos;  AnnotationGraph graph;    // declare local variables  //  Long* tag;    // determine if the identifier exists in the database  //  tag = hash_index_d.get(identifier_a);  if (tag == (Long*)NULL) {    return false;  }    // when the identifier exists in the database return a copy of the record  //  else {    graph.clear();    if (!graph.read(database_sof_d, (long)*tag)) {      Error::handle(name(), L"getReord", Error::NO_PARAM_FILE,		    __FILE__, __LINE__);          }    // retrieve the list of records from the database that contains    // the features    //    // get the annotations with the given features    //    if (!graph.getAnnotationSetByFeature(feature_a, value_a, annos)) {      return Error::handle(name(), L"getRecord - unable to find the annotation for the given feature and the value", Error::ARG, __FILE__, __LINE__);          }    // add the annotation labels to the list    //    for (boolean more=annos.gotoFirst(); more; more=annos.gotoNext()) {      tmpstr.assign(annos.getCurr()->getType());      records_a.insert(&tmpstr);    }  }  // clean up memory  //  graph.clear();    // exit gracefully  //  return true;}// method: getRecord//// arguments://  String& identifier: (input) annotation graph id//  String& feature: (input) annotation feature//  String& value: (input) annotation feature value//  DoubleLinkedList<Annotation>& records: (output) list of records//// return: logical error status//// this method retrieves the record from the database//boolean TranscriptionDatabase::getRecord(String& identifier_a,					 String& feature_a, String& value_a,				  DoubleLinkedList<Annotation>& records_a) {  // declare local variables  //  AnnotationGraph graph;  DoubleLinkedList<Annotation> records;    // declare local variables  //  Long* tag;    // determine if the identifier exists in the database  //  tag = hash_index_d.get(identifier_a);  if (tag == (Long*)NULL) {    return false;  }    // when the identifier exists in the database return a copy of the record  //  else {    graph.clear();    if (!graph.read(database_sof_d, (long)*tag)) {      Error::handle(name(), L"getRecord", Error::NO_PARAM_FILE,		    __FILE__, __LINE__);          }        // retrieve the list of records from the database that contains    // the features    //    else {      // get the annotations with the given features      //      if (!graph.getAnnotationSetByFeature(feature_a, value_a, records)) {	return false;      }    }  }  records_a.assign(records);  // clean up memory  //  graph.clear();    // exit gracefully  //  return true;}// method: getRecord//// arguments://  String& identifier: (input) annotation graph id//  Vector<String>& values: (input) annotation feature values corresponding//                          to  feature-name "level"//  String& record: (output) alignments//// return: logical error status//// this method retrieves the alignment from the database//boolean TranscriptionDatabase::getRecord(String& identifier_a,					 Vector<String>& values_a,					 String& record_a) {    // declare local variables  //  DoubleLinkedList<Annotation> annos;  AnnotationGraph graph;    Long* tag;  String fea_name(L"level");  String fea_score(L"score");    // check for input values  //  if (values_a.length() <= long(0)) {    Error::handle(name(), L"getRecord - levels missing", Error::ARG,		  __FILE__, __LINE__);        }    // determine if the identifier exists in the database  //  tag = hash_index_d.get(identifier_a);  if (tag == (Long*)NULL) {    Error::handle(name(), L"getRecord - annotation-graph missing", Error::ARG,		  __FILE__, __LINE__);        }    // when the identifier exists in the database return a copy of the record  //  else {    graph.clear();    if (!graph.read(database_sof_d, (long)*tag)) {      Error::handle(name(), L"getRecord", Error::ARG,		    __FILE__, __LINE__);          }    // loop over all the required levels    //    for (long i = 0; i < values_a.length(); i++) {          // get all the annotations at feature "level" and value starting      // with the top-most level      //      if (!graph.getAnnotationSetByFeature(fea_name, values_a(i), annos)) {	return Error::handle(name(), L"getRecord - unable to find the annotations for the given feature and the value", Error::ARG, __FILE__, __LINE__);      }      // update the output alignment format      //      record_a.concat(L"\n");      record_a.concat(L"  ");      record_a.concat(fea_name);      record_a.concat(L": ");      record_a.concat(values_a(i));          // loop over each annotation at this level      //      Annotation* anno = (Annotation*)NULL;      for (boolean more = annos.gotoFirst(); more; more = annos.gotoNext()) {	anno = (Annotation*)NULL;	anno = annos.getCurr();	// check the annotation for NULL	//	if (anno == (Annotation*)NULL) {	  return Error::handle(name(), L"getRecord - NULL Annotation",			       Error::ARG, __FILE__, __LINE__);	}		// get the type and the score at this annotation	//	String type;	String score;	type.assign(anno->getType());	score.assign(anno->getFeature(fea_score));		// get start and end anchors for the current annotation	//	Anchor* anch_start = (Anchor*)NULL;	Anchor* anch_end = (Anchor*)NULL;	anch_start = anno->getStartAnchor();	anch_end = anno->getEndAnchor();		// check for NULL anchors	//	if ((anch_start == (Anchor*)NULL) || (anch_end == (Anchor*)NULL)) {	  return Error::handle(name(), L"getRecord - NULL Anchors",			       Error::ARG, __FILE__, __LINE__);	}		// get the unit and offset from the start and end anchors	//	String unit_start;	String unit_end;	unit_start.assign(anch_start->getUnit());	unit_end.assign(anch_end->getUnit());	float offset_start;	float offset_end;	offset_start = anch_start->getOffset();	offset_end = anch_end->getOffset();	// update the output alignment format	//	record_a.concat(L"\n");	record_a.concat(L"    from");	record_a.concat(L": ");	record_a.concat(offset_start);	record_a.concat(L" ");	record_a.concat(unit_start);	record_a.concat(L"  to");	record_a.concat(L": ");	record_a.concat(offset_end);	record_a.concat(L" ");	record_a.concat(unit_end);	record_a.concat(L"  ");	record_a.concat(type);	record_a.concat(L"  ");	record_a.concat(score);      }      // update the output alignment format      //      record_a.concat(L"\n");    }        // update the output alignment format    //    record_a.concat(L"\n");  }  // clean up memory  //  graph.clear();    // exit gracefully  //  return true;}// method: getHypothesesNistTrn//// arguments://  Sdb& ident_list_sdb: (input) list of identifier//  Sdb& exlude_symbols_sdb: (input) list of exclude_symbols//  String& fvalue: (input) annotation feature value (transcription level)//  Vector<String>& nist_hypotheses: (output) vector of NIST_TRN format//                                    hypotheses//// return: logical error status//// this method retrieves the hypotheses at a given feature (level)// from the database in NIST_TRN format//boolean TranscriptionDatabase::getHypothesesNistTrn(Sdb& ident_list_sdb_a,						    Sdb& exclude_symbols_sdb_a,						    String& fvalue_a,						    Vector<String>&						    nist_hypotheses_a) {    // declare local variables  //  String identifier;  Filename input_ID;  long num_ident = (long)0;    // set the capacity of the output vector to the length of the input  // identifiers  //  nist_hypotheses_a.setCapacity(ident_list_sdb_a.length());				  // default feature name for transcriptions  //  String fname(L"level");      // loop over all the identifiers and extract the hypotheses  // corresponding to each  //  for (ident_list_sdb_a.gotoFirst(); ident_list_sdb_a.getName(input_ID);       ident_list_sdb_a.gotoNext()) {

⌨️ 快捷键说明

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