00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 #if !defined(ALIZE_IOFormat_cpp)
00056 #define ALIZE_IOFormat_cpp
00057
00058 #include <iostream>
00059 #include <fstream>
00060 #include <cstdio>
00061 #include <cassert>
00062 #include <cmath>
00063 #include <liatools.h>
00064 #include "IOFormat.h"
00065
00066
00067
00068
00069
00070
00071 void outputWeightVector(MixtureGD& world,MixtureGD& clientMixture, double frameCount, Config& config) {
00072 String fileName=config.getParam("vectorFilesPath")+clientMixture.getId()+config.getParam("vectorFilesExtension");
00073 if (verbose) cerr << "Output Weights Transformation Parameters to:" << fileName << endl;
00074 double w,c,feat;
00075 ofstream paramFile(fileName.c_str());
00076 for (unsigned long i=0;i<world.getDistribCount();i++) {
00077 w=world.weight(i);
00078 c=clientMixture.weight(i);
00079 feat=c/sqrt(w);
00080 paramFile << feat << " ";
00081 }
00082 paramFile << endl;
00083 paramFile.close();
00084 }
00085
00086
00087 void outputSVMLightVector(RealVector<double>&v, const String &id, Config& config) {
00088 String fileName=config.getParam("vectorFilesPath")+id+config.getParam("vectorFilesExtension");
00089 ofstream paramFile(fileName.c_str());
00090 paramFile << "1 ";
00091 for (unsigned long i=0;i<v.size();i++)
00092 paramFile <<i+1<< ":" << v[i] << " ";
00093 paramFile << endl;
00094 paramFile.close();
00095 }
00096
00097
00098
00099 void outputDSM(DoubleSquareMatrix & W,MixtureGD& clientMixture,Config& config) {
00100 String fileName=config.getParam("vectorFilesPath")+clientMixture.getId()+config.getParam("vectorFilesExtension");
00101 if (verbose) cout << "Output MLLR Matrix to:" << fileName << endl;
00102 ofstream out(fileName.c_str());
00103 for (unsigned long i=0;i<W.size()-1;i++)
00104 for (unsigned long j=0;j<W.size();j++)
00105 out << W(i,j) << " ";
00106 out << endl;
00107 out.close();
00108 }
00109
00110
00111
00112 void outputResultLine(double LLR, const String & clientName, const String & seg, const String &gender, int decision, ostream& strm)
00113 {
00114 strm << gender<<" "<<clientName<<" "<< decision <<" "<<seg <<" "<< LLR << endl;
00115 }
00116
00117 void outputResultLine(double LLR, const String & clientName, const String & seg,real_t begin,real_t end, const String &gender, int decision, ostream& strm)
00118 {
00119 strm << gender<< " "<<clientName<<" "<< decision <<" "<<seg <<" "<< begin << " "<< end<< " "<< LLR << endl;
00120 }
00121
00122
00123
00124 void outputResultLIARALLine(const String &gender, const String & clientName, const String & channel, const String & seg, const String & start, const String & duration, double LLR, ostream& strm)
00125 {
00126 strm <<gender<<" "<<clientName<<" "<<channel<<" "<<seg<<" "<<start<<" "<<duration<<" "<<LLR<< endl;
00127 }
00128
00129
00130
00131 void outputResultNIST04Line(const String &trainTypeTest, const String &adaptationMode, const String &segTypeTest, const String &gender, const String & clientName, const String & seg, const String &decision, double LLR, ostream& strm)
00132 {
00133 strm <<trainTypeTest<<" "<<adaptationMode<<" "<<segTypeTest<<" "<<gender<<" "<<clientName<<" "<<seg<<" "<<decision<<" "<<LLR<< endl;
00134 }
00135
00136
00137
00138 void outputResultETFLine(const String &source, const String &channel, const String &start, double duration, const String &type, const String &sub, const String &event, double score, const String &decision, ostream& strm)
00139 {
00140 strm <<source<< " "<<channel<<" "<<start<<" "<<duration<<" "<<type<< " "<<sub<< " "<<event<<" "<<score<<" "<<decision<<endl;
00141 }
00142
00143
00144
00145 void outputResultMDTMLine(const String &source, const String &channel, const String &start, double duration, const String &type, double conf, const String &sub, ostream& strm)
00146 {
00147 strm <<source<< " "<<channel<<" "<<start<<" "<<duration<<" "<<type<< " "<<conf<< " "<<sub<<endl;
00148 }
00149
00150
00151
00152
00153
00154
00155 void setLIAInfoFields(unsigned long & genderField, unsigned long & nameField, unsigned long & decisionField, unsigned long & segField, unsigned long & scoreField)
00156 {
00157 genderField=0;
00158 nameField=1;
00159 decisionField=2;
00160 segField=3;
00161 scoreField=4;
00162 }
00163
00164
00165 void setNIST04InfoFields(unsigned long & genderField, unsigned long & nameField, unsigned long & decisionField, unsigned long & segField, unsigned long & scoreField)
00166 {
00167 genderField=3;
00168 nameField=4;
00169 decisionField=6;
00170 segField=5;
00171 scoreField=7;
00172 }
00173
00174
00175 #endif //!defined(ALIZE_IOFormat_cpp)