本文整理汇总了C++中XList类的典型用法代码示例。如果您正苦于以下问题:C++ XList类的具体用法?C++ XList怎么用?C++ XList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XList类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1:
FactorAnalysisStat::FactorAnalysisStat(String & featFilename,FeatureServer & fs,Config & config):_ms(config),_ss(config){ // constructor for a single file
XList faNdx;
XLine featLine;
featLine.addElement(featFilename);
faNdx.addLine()=featLine;
_init(faNdx,fs,config);
}
开发者ID:ftahmed,项目名称:LIA_RAL,代码行数:7,代码来源:FactorAnalysis.cpp
示例2: getTarClientIdx
//-------------------------------------------------------------------------
// Get a tab with indexes of speakers with maximum likelihood (mdtm and etf only)
void getTarClientIdx(Config & config, XList & inputList, unsigned long nbLoc, unsigned long * tarTab)
{
XLine *linep;
unsigned long cpt=0;
unsigned long cpttab=0;
double minLLK=config.getParam("minLLK").toDouble();
double maxScore=minLLK;
unsigned long idxTar=0;
bool verbose=config.existsParam("verbose");
while((linep=inputList.getLine())!=NULL)
{
double score=linep->getElement(6).toDouble();
if (score>=maxScore)
{
maxScore=score; // this is the maximum score
idxTar=cpt; // index is just the line
if (verbose) {cout << "giving highest score to " << linep->getElement(1) << " "<<maxScore << endl;}
}
if (cpt%nbLoc==(nbLoc-1)) // when changing segment
{
tarTab[cpttab]=idxTar; // idx of the target goes in the tab
if (verbose) {cout << linep->getElement(1) << " max score: "<<maxScore <<"idx: "<<idxTar<<"cpt: "<<cpt<< endl;}
cpttab++;
maxScore=minLLK; //reset maxScore
}
cpt++;
}
}
开发者ID:ALIZE-Speaker-Recognition,项目名称:LIA_RAL,代码行数:31,代码来源:Scoring.cpp
示例3: getIndexOfMaxScore
//-------------------------------------------------------------------------
//
unsigned long getIndexOfMaxScore(XList & inputList,unsigned long scoreField, unsigned long segField, unsigned long & i, unsigned long nbListLines)
{
String seg=inputList.getLine(i).getElement(segField); //this is a new segment
long max_score=-200;
long score;
unsigned long maxIndex=0;
while (inputList.getLine(i).getElement(segField)==seg) // while same segment test
{
score= inputList.getLine(i).getElement(scoreField).toLong();
if (score >= max_score) {max_score=score; maxIndex=i;} // store max score and its index
i++;
if (i >= nbListLines) break; // break the loop if end of file
}
return maxIndex;
}
开发者ID:ALIZE-Speaker-Recognition,项目名称:LIA_RAL,代码行数:18,代码来源:Scoring.cpp
示例4: task3
// this function is what is required by task #3 here: https://sites.google.com/site/kostovoop/tasks
// Составить и отладить программу:
// - создать некий XList фигур, наполнить его случайным образом конкретными фигурами всех типов;
// - вывести в std::cout общее кол-во фигур с помощью Shape::GetCount();
// - напечатать в std::cout сведения обо всех фигурах, находящихся в списке;
// - очистить память;
// - вывести в std::cout общее кол-во фигур с помощью Shape::GetCount() – удостовериться, что там 0;
// - завершить работу программы.
void task3()
{
XList<Shape> shapesList;
// pt, circle, rect, square, polyline
Point * pt = new Point("a point", 10, 100); // 1
Circle * circle = new Circle("a circle", 30, Point("circle center", 10, 20)); // 2
Rect * rect = new Rect("a rect", 10, -30, 10, -100); // 2
Square * square = new Square("a square", 40, 20, 10); // 2
Polyline * line = new Polyline("line"); // 1
Point * pt1 = new Point("", 10, 20);
Point * pt2 = new Point("", 20, 20);
Point * pt3 = new Point("", 20, 40);
Point * pt4 = new Point("", 10, 40);
line->AddPoint(*pt1);
line->AddPoint(*pt2);
line->AddPoint(*pt3);
line->AddPoint(*pt4);
shapesList.pushBack(pt);
shapesList.pushBack(circle);
shapesList.pushBack(rect);
shapesList.pushBack(square);
shapesList.pushBack(line);
std::cout << "Total number of shapes is: " << Shape::getCount() << std::endl;
assert(Shape::getCount() == 16); // 5 figures in list and their copies, 4 points in the polyline, rect's origin, square's origin, circle's center
XList<Shape>::Iterator it = shapesList.begin();
int l = shapesList.numberOfElements() + 1;
while(--l > 0){
Shape * shape = it.currentItem();
std::cout << *shape << std::endl;
it.next();
}
shapesList.clearList();
// freeing memory
delete pt;
delete circle;
delete square;
delete rect;
delete line;
delete pt1;
delete pt2;
delete pt3;
delete pt4;
std::cout << "Total number of shapes is now: " << Shape::getCount() << std::endl;
assert(Shape::getCount() == 0);
}
开发者ID:stkhapugin,项目名称:Kostov-OOP,代码行数:60,代码来源:main.cpp
示例5: AVIopen
int AVIopen(char *filename,int flags,int channel,void **avi)
{
AVIFile *newavi = new AVIFile;
if(!newavi -> open(filename,flags,channel))
return 0;
*avi = newavi;
aviXList.AddElement((XListElement*)newavi);
xtRegisterSysFinitFnc(FinitAVI,XAVI_SYSOBJ_ID);
return 1;
}
开发者ID:kvark,项目名称:Vangers,代码行数:13,代码来源:avi.cpp
示例6: main
void main()
{
XList<Shape *> shapes;
for (int i = 0; i < 5; i++)
{
shapes.AddLast(ShapeFactory::CreateShape(circle));
shapes.AddLast(ShapeFactory::CreateShape(point));
shapes.AddLast(ShapeFactory::CreateShape(rect));
shapes.AddLast(ShapeFactory::CreateShape(polyline));
shapes.AddLast(ShapeFactory::CreateShape(polygone));
}
std::cout << "shapes:" << Shape::GetCount() << std::endl;
std::cout << "points:" << Point::GetCount() << std::endl;
std::cout << "circles:" << Circle::GetCount() << std::endl;
std::cout << "rect:" << Rect::GetCount() << std::endl;
std::cout << "polyline:" << Polyline::GetCount() << std::endl;
std::cout << "polygone:" << Polygone::GetCount() << std::endl << std::endl;
for (int i = 0; i < shapes.GetSize(); i++)
std::cout << *dynamic_cast<Printable *>(shapes.GetByIndex(i)) << std::endl;
for (size_t i = 0; i < (size_t)shapes.GetSize(); i++)
delete shapes.GetByIndex(i);
std::cout << std::endl;
std::cout << "shapes:" << Shape::GetCount() << std::endl;
std::cout << "points:" << Point::GetCount() << std::endl;
std::cout << "circles:" << Circle::GetCount() << std::endl;
std::cout << "rect:" << Rect::GetCount() << std::endl;
std::cout << "polyline:" << Polyline::GetCount() << std::endl;
std::cout << "polygone:" << Polygone::GetCount() << std::endl << std::endl;
_getch();
}
开发者ID:Ktkachev,项目名称:CppTask,代码行数:40,代码来源:main.cpp
示例7: getSegmentalMeanCovWithoutMax
//-------------------------------------------------------------------------
// Produce a tab with mean and cov by segment without the maximum score(mdtm and etf only)
void getSegmentalMeanCovWithoutMax(Config & config, XList & inputList, unsigned long nbLoc, unsigned long * tarTab, double* meanTab, double * covTab)
{
XLine *linep;
unsigned long cpt=0;
unsigned long cpttab=0;
double minLLK=config.getParam("minLLK").toDouble();
double maxScore=minLLK;
double meanAcc=0.0;
double covAcc=0.0;
unsigned long idxTar=0;
bool verbose=config.existsParam("verbose");
while((linep=inputList.getLine())!=NULL)
{
double score=linep->getElement(6).toDouble();
if (score>=maxScore)
{
maxScore=score; // this is the maximum score
idxTar=cpt; // index is just the line
if (verbose) {cout << "giving highest score to " << linep->getElement(1) << " "<<maxScore << endl;}
}
meanAcc+=score; // Accumulate mean and cov
covAcc+=(score*score);
if (cpt%nbLoc==(nbLoc-1)) // when changing segment
{
tarTab[cpttab]=idxTar;
meanAcc-=maxScore; //remove max from Stats
covAcc-=(maxScore*maxScore);
meanTab[cpttab]=meanAcc;
covTab[cpttab]=covAcc;
if (verbose) {cout << linep->getElement(1) << " max score: "<<maxScore <<"idx: "<<idxTar<<"cpt: "<<cpt<< " meanA: "<<meanAcc<<" covA: "<<covAcc<<endl;}
cpttab++;
maxScore=minLLK;
meanAcc=0.0;
covAcc=0.0;
}
cpt++;
}
}
开发者ID:ALIZE-Speaker-Recognition,项目名称:LIA_RAL,代码行数:42,代码来源:Scoring.cpp
示例8: getSegmentalMeanCov
//-------------------------------------------------------------------------
// Produce a tab with mean and cov by segment (mdtm and etf only)
void getSegmentalMeanCov(XList & inputList, unsigned long nbLoc, double* meanTab, double * covTab)
{
XLine *linep;
unsigned long cpt=0;
unsigned long cpttab=0;
double meanAcc=0.0;
double covAcc=0.0;
while((linep=inputList.getLine())!=NULL)
{
double score=linep->getElement(6).toDouble();
meanAcc+=score; // Accumulate mean and cov
covAcc+=(score*score);
if (cpt%nbLoc==(nbLoc-1)) // when changing segment
{
meanTab[cpttab]=meanAcc;
covTab[cpttab]=covAcc;
cpttab++;
meanAcc=0.0;
covAcc=0.0;
}
cpt++;
}
}
开发者ID:ALIZE-Speaker-Recognition,项目名称:LIA_RAL,代码行数:26,代码来源:Scoring.cpp
示例9: AVIclose
void AVIclose(void *avi)
{
AVIFile* p = (AVIFile*)avi;
aviXList.RemoveElement((XListElement*)p);
delete p;
}
开发者ID:kvark,项目名称:Vangers,代码行数:6,代码来源:avi.cpp
示例10: main
int main()
{
XList<int> list;
XList<int>::iterator it;
XList<int>::reverse_iterator rit;
list.push_back(11);
list.push_front(8);
list.push_back(12);
list.push_back(13);
list.push_back(14);
list.print();
std::cout<<list.size()<<std::endl;
it = list.begin();
std::cout<<*(++it)<<std::endl;
for (it = list.begin(); it != list.end(); ++it)
std::cout<<*it<<" ";
std::cout<<std::endl;
for (rit = list.rbegin(); rit != list.rend(); ++rit)
std::cout<<*rit<<" ";
std::cout<<std::endl;
it = list.end();
return 0;
}
开发者ID:Eldar7,项目名称:OOPcpp,代码行数:30,代码来源:main.cpp
示例11: launchTurnDetectionProcess
void launchTurnDetectionProcess(Config & config){
String outputFilesPath=config.getParam("outputFilesPath");
String inputListFileName = config.getParam("listFileToSegment"); //file including the list of files to segment
XLine classToAnalyse; //Array of labels to analyze
classToAnalyse.reset();
if(verbose){
cout << "*********** Current Configuration ***************" << endl;
for(unsigned long i=0; i<config.getParamCount(); i++){
cout << config.getParamName(i) << " => " << config.getParamContent(i) << endl;
}
cout << "*************************************************" << endl;
}
try{
XList listLabel;
XList listFileName;
try{
listFileName.load(inputListFileName,config);
}
catch(FileNotFoundException& e){
cout<<"There is no files to segment !"<<endl;
exit(-1);
}
listFileName.rewind();
XLine *filep;
while ((filep=listFileName.getLine()) != NULL){ // For each stream of audio data (in several files in the same line)
const XLine & listFile=filep->getElements(); // One or several files, as several part of the same stream
MixtureServer ms(config);
StatServer ss(config, ms);
SegServer Resultat;
FeatureServer fs(config,listFile); // Reading the features (one or more files)
SegServer segmentsServer; // Create the segment server for managing the segments/clusters
LabelServer labelServer; // Create the lable server, for indexing the segments/clusters
initializeClusters(listFile,segmentsServer,labelServer,config); // Reading the segmentation files for each feature input file
verifyClusterFile(segmentsServer,fs,config); // Verify if the segments ending before the end of the feature files
String fileInit=listFile.getElement(0);
config.setParam("fileSize", String::valueOf(fs.getFeatureCountOfASource(fileInit)));
if(config.existsParam("fileRefPath")){
// assumption: all the segments in the segment server come from the same source file !!!
displayAllSegmentsFromRef(config, fileInit, fs.getFeatureCountOfASource(fileInit));
}
for(unsigned long icluster=0;icluster<segmentsServer.getClusterCount();icluster++){ // for each cluster
SegCluster& cluster=segmentsServer.getCluster(icluster);
SegServer segOutputServer;
TurnDetection(config,cluster,segOutputServer,ss,fs,ms,labelServer);
displayAllSegments(config,segOutputServer);
for(unsigned long i=0;i<segOutputServer.getSegCount();i++){
Seg& segment=segOutputServer.getSeg(i);
Resultat.createSeg(segment.begin(),segment.length(),segment.labelCode(),segment.string(),segment.sourceName());
}
}//for icluster
saveSegmentation(config,Resultat,fs,outputFilesPath,1);
}// while
} // end try
catch (Exception& e){
cout << e.toString().c_str() << endl;
}
}//launchTurnDetectionProcess
开发者ID:orsonwang,项目名称:ALIZE-LIA_RAL-extensions,代码行数:63,代码来源:TurnDetection.cpp
示例12: IvExtractorEigenDecomposition
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
int IvExtractorEigenDecomposition(Config& config)
{
String inputWorldFilename = config.getParam("inputWorldFilename");
// label for selected frames - Only the frames associated with this label, in the label files, will be used
bool fixedLabelSelectedFrame=true;
String labelSelectedFrames;
if (config.existsParam("useIdForSelectedFrame")) // the ID of each speaker is used as labelSelectedFrame ?
fixedLabelSelectedFrame=(config.getParam("useIdForSelectedFrame").toBool()==false);
if (fixedLabelSelectedFrame) // the label is decided by the command line and is unique for the run
labelSelectedFrames=config.getParam("labelSelectedFrames");
try{
MixtureServer ms(config);
if (verbose) cout << "(IvExtractor) Approximate i-vector by using Eigen Decomposition"<<endl;
if (verbose) cout << "(IvExtractor) TotalVariability - Load world model [" << inputWorldFilename<<"]"<<endl;
MixtureGD& world = ms.loadMixtureGD(inputWorldFilename);
//Read the NDX file
String ndxFilename = config.getParam("targetIdList");
//Remove the first element of each line which is the model name
XList tmpFileList(ndxFilename);
XList fileList;
for(unsigned long ll=0;ll<tmpFileList.getLineCount();ll++){
fileList.addLine();
for(unsigned long i=1;i<tmpFileList.getLine()->getElementCount();i++){
fileList.getLine(fileList.getLineCount()-1).addElement(tmpFileList.getLine(ll).getElement(i));
}
}
//Create and initialise the accumulator
TVAcc tvAcc(fileList, config);
Matrix<double> Q(tvAcc.getRankT(),tvAcc.getRankT());
Matrix<double> D(tvAcc.getNDistrib(),tvAcc.getRankT());
if(config.existsParam("loadEigenDecompositionParam") && config.getParam("loadEigenDecompositionParam").toBool()){ // Load normalized T matrix and weighted Covariance matrix if pre-computed
//Load TotalVariability matrix
String normTFilename = config.getParam("totalVariabilityMatrix") + "_norm";
tvAcc.loadT(normTFilename, config);
//Load D and Q matrices
String dFilename = config.getParam("matrixFilesPath") + config.getParam("totalVariabilityMatrix") + "_EigDec_D" + config.getParam("loadMatrixFilesExtension");
D.load(dFilename,config);
String qFilename = config.getParam("matrixFilesPath") + config.getParam("totalVariabilityMatrix") + "_EigDec_Q" + config.getParam("loadMatrixFilesExtension");
Q.load(qFilename,config);
}
else{
//Load TotalVariability matrix
tvAcc.loadT(config.getParam("totalVariabilityMatrix"), config);
// Normalize matrix T
tvAcc.normTMatrix();
// Compute weighted co-variance matrix by using UBM weight coefficients
DoubleSquareMatrix W(tvAcc.getRankT());
W.setAllValues(0.0);
tvAcc.getWeightedCov(W,world.getTabWeight(),config);
// Eigen Decomposition of W to get Q
Matrix<double> tmpW(W);
Q.setAllValues(0.0);
tvAcc.computeEigenProblem(tmpW,Q,tvAcc.getRankT(),config);
// Compute D matrices (approximation of Tc'Tc matrices)
D.setAllValues(0.0);
tvAcc.approximateTcTc(D,Q,config);
}
//Load the statistics from files or compute statistics for all segments at once
if((config.existsParam("loadAccs")) && config.getParam("loadAccs").toBool()){ //load pre-computed statistics
cout<<" (IvExtractor) Load Accumulators"<<endl;
tvAcc.loadN(config);
tvAcc.loadF_X(config);
}
else{ //Compute statistics if they don't exists
tvAcc.computeAndAccumulateTVStat(config);
tvAcc.saveAccs(config);
}
// Then load the meanEstimate computed by minDiv if required
DoubleVector meanEstimate = tvAcc.getUbmMeans();
if(config.existsParam("minDivergence")&& config.getParam("minDivergence").toBool()){
String minDivName = config.getParam("matrixFilesPath") + config.getParam("meanEstimate") + config.getParam("loadMatrixFilesExtension");
Matrix<double> tmpMean(minDivName,config);
for(unsigned long i=0;i<meanEstimate.size();i++){
meanEstimate[i] = tmpMean(0,i);
}
}
//Update the mean Estimate
cout<<" (IvExtractor) Load Mean Estimate"<<endl;
tvAcc.loadMeanEstimate(meanEstimate);
//Substract mean from the statistics and normalize co-variance
tvAcc.normStatistics(config);
//.........这里部分代码省略.........
开发者ID:orsonwang,项目名称:ALIZE-LIA_RAL-extensions,代码行数:101,代码来源:IvExtractor.cpp
示例13: IvExtractor
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
int IvExtractor(Config& config)
{
String inputWorldFilename = config.getParam("inputWorldFilename");
// label for selected frames - Only the frames associated with this label, in the label files, will be used
bool fixedLabelSelectedFrame=true;
String labelSelectedFrames;
if (config.existsParam("useIdForSelectedFrame")) // the ID of each speaker is used as labelSelectedFrame ?
fixedLabelSelectedFrame=(config.getParam("useIdForSelectedFrame").toBool()==false);
if (fixedLabelSelectedFrame) // the label is decided by the command line and is unique for the run
labelSelectedFrames=config.getParam("labelSelectedFrames");
try{
MixtureServer ms(config);
if (verbose) cout << "(IvExtractor) TotalVariability - Load world model [" << inputWorldFilename<<"]"<<endl;
MixtureGD& world = ms.loadMixtureGD(inputWorldFilename);
//Load the statistics from files or compute statistics for all segments at once
//Read the NDX file
String ndxFilename = config.getParam("targetIdList");
//Remove the first element of each line which is the model name
XList tmpFileList(ndxFilename);
XList fileList;
for(unsigned long ll=0;ll<tmpFileList.getLineCount();ll++){
fileList.addLine();
for(unsigned long i=1;i<tmpFileList.getLine()->getElementCount();i++){
fileList.getLine(fileList.getLineCount()-1).addElement(tmpFileList.getLine(ll).getElement(i));
}
}
//Create and initialise the accumulator
TVAcc tvAcc(fileList, config);
//Load TotalVariability matrix
tvAcc.loadT(config.getParam("totalVariabilityMatrix"), config);
//Statistics
if((config.existsParam("loadAccs")) && config.getParam("loadAccs").toBool()){ //load pre-computed statistics
cout<<" (IvExtractor) Load Accumulators"<<endl;
tvAcc.loadN(config);
tvAcc.loadF_X(config);
}
else{ //Compute statistics if they don't exists
tvAcc.computeAndAccumulateTVStat(config);
tvAcc.saveAccs(config);
}
// Then load the meanEstimate computed by minDiv if required
DoubleVector meanEstimate = tvAcc.getUbmMeans();
if(config.existsParam("minDivergence")&& config.getParam("minDivergence").toBool()){
String minDivName = config.getParam("matrixFilesPath") + config.getParam("meanEstimate") + config.getParam("loadMatrixFilesExtension");
Matrix<double> tmpMean(minDivName,config);
for(unsigned long i=0;i<meanEstimate.size();i++){
meanEstimate[i] = tmpMean(0,i);
}
}
//Update the mean Estimate
cout<<" (IvExtractor) Load Mean Estimate"<<endl;
tvAcc.loadMeanEstimate(meanEstimate);
//Substract mean from the statistics
tvAcc.substractM(config);
//Compute vEvT for each session
tvAcc.estimateTETt(config);
// Estimate I-Vectors
tvAcc.estimateW(config);
cout<<"--------- save IV by File --------"<<endl;
tvAcc.saveWbyFile(config);
cout<<"--------- end of process --------"<<endl;
} // fin try
catch (Exception& e) {cout << e.toString().c_str() << endl;}
return 0;
}
开发者ID:orsonwang,项目名称:ALIZE-LIA_RAL-extensions,代码行数:79,代码来源:IvExtractor.cpp
示例14: TrainTargetLFA
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
int TrainTargetLFA(Config& config)
{
String inputClientListFileName = config.getParam("targetIdList");
String inputWorldFilename = config.getParam("inputWorldFilename");
String outputSERVERFilename = "";
if (config.existsParam("mixtureServer")) outputSERVERFilename =config.getParam("mixtureServer");
bool initByClient=false; // In this case, the init model is read from the file
if (config.existsParam("initByClient")) initByClient=config.getParam("initByClient").toBool();
bool saveEmptyModel=false;
if (config.existsParam("saveEmptyModel")) saveEmptyModel=config.getParam("saveEmptyModel").toBool();
// label for selected frames - Only the frames associated with this label, in the label files, will be used
bool fixedLabelSelectedFrame=true;
String labelSelectedFrames;
if (config.existsParam("useIdForSelectedFrame")) // the ID of each speaker is used as labelSelectedFrame ?
fixedLabelSelectedFrame=(config.getParam("useIdForSelectedFrame").toBool()==false);
if (fixedLabelSelectedFrame) // the label is decided by the command line and is unique for the run
labelSelectedFrames=config.getParam("labelSelectedFrames");
bool modelData=false;
if (config.existsParam("useModelData")) modelData=config.getParam("useModelData").toBool();
String initModelS=inputWorldFilename;
if (modelData) if (config.existsParam("initModel")) initModelS=config.getParam("initModel"); // Use a specific model for Em init
bool outputAdaptParam=false;
if (config.existsParam("superVectors")) outputAdaptParam=true;
try{
XList inputClientList(inputClientListFileName,config); // read the Id + filenames for each client
XLine * linep;
inputClientList.getLine(0);
MixtureServer ms(config);
StatServer ss(config, ms);
if (verbose) cout << "(TrainTarget) Latent Factor Analysis - Load world model [" << inputWorldFilename<<"]"<<endl;
MixtureGD& world = ms.loadMixtureGD(inputWorldFilename);
if (verbose) cout <<"(TrainTarget) Use["<<initModelS<<"] for initializing EM"<<endl;
//LOAD JFA MAtrices
unsigned long svsize=world.getDistribCount()*world.getVectSize();
Matrix<double> U, V;
DoubleVector D(svsize,svsize);
//Initialise EC matrix
if(config.existsParam("eigenChannelMatrix")){
String uName = config.getParam("matrixFilesPath") + config.getParam("eigenChannelMatrix") + config.getParam("loadMatrixFilesExtension");
U.load (uName, config);
if (verboseLevel >=1) cout << "(TrainTargetLFA) Init EC matrix from "<< config.getParam("eigenChannelMatrix") <<" from EigenChannel Matrix: "<<", rank: ["<<U.rows() << "] sv size: [" << U.cols() <<"]"<<endl;
}
else{
U.setDimensions(1,svsize);
U.setAllValues(0.0);
if (verboseLevel >1) cout << "(TrainTargetLFA) Init EC matrix to 0"<<endl;
}
V.setDimensions(1,svsize);
V.setAllValues(0.0);
if (verboseLevel >=1) cout << "(TrainTargetLFA) Init EV matrix to 0"<<endl;
//Initialise the D matrix for MAP adaptation
for(unsigned long i=0; i<world.getDistribCount(); i++){
for(unsigned long j = 0; j<world.getVectSize(); j++){
D[i*world.getVectSize()+j] = sqrt(1.0/(world.getDistrib(i).getCovInv(j)*config.getParam("regulationFactor").toDouble()));
}
}
// *********** Target loop *****************
while ((linep=inputClientList.getLine()) != NULL){ // linep gives the XLine with the Id of a given client and the list of files
String *id=linep->getElement(); // Get the Client ID (id)
XLine featureFileListp=linep->getElements(); // Get the list of feature file for the client (end of the line)
if (verbose) cout << "(TrainTargetLFA) Train model ["<<*id<<"]"<<endl;
XList ndx; ndx.addLine() = featureFileListp;
JFAAcc jfaAcc(ndx,config,"TrainTarget");
//Charger les matrices V, U et D a partir des objets matrice existant.
jfaAcc.loadEV(V, config); jfaAcc.loadEC(U, config); jfaAcc.loadD(D);
//Initialise VU matrix
jfaAcc.initVU();
FeatureServer fs(config,featureFileListp); // Reading the features (from several files)
SegServer segmentsServer; // Create the segment server for managing the segments/clusters
LabelServer labelServer; // Create the lable server, for indexing the segments/clusters
initializeClusters(featureFileListp,segmentsServer,labelServer,config); // Reading the segmentation files for each feature input file
verifyClusterFile(segmentsServer,fs,config); // Verify if the segments ending before the end of the feature files...
MixtureGD & adaptedMixture = ms.duplicateMixture(world,DUPL_DISTRIB); // Creating final as a copy of the world model
MixtureGD & clientMixture= ms.duplicateMixture(world,DUPL_DISTRIB);
long codeSelectedFrame=labelServer.getLabelIndexByString(labelSelectedFrames); // Get the index of the cluster with in interest audio segments
if (codeSelectedFrame==-1){ // No data for this model !!!!!!!!!!!!!!
cout << " WARNING - NO DATA FOR TRAINING ["<<*id<<"]";
if (saveEmptyModel){
cout <<" World model is returned"<<endl; // In this case, the client model is the world model
if (verbose) cout << "Save client model ["<<*id<<"]" << endl;
adaptedMixture.save(*id, config); // Save the client model
}
}
else{
SegCluster& selectedSegments=segmentsServer.getCluster(codeSelectedFrame); // Gives the cluster of the selected/used segments
//.........这里部分代码省略.........
开发者ID:orsonwang,项目名称:ALIZE-LIA_RAL-extensions,代码行数:101,代码来源:TrainTarget.cpp
示例15: TrainTargetJFA
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
int TrainTargetJFA(Config& config)
{
String inputClientListFileName = config.getParam("targetIdList");
String inputWorldFilename = config.getParam("inputWorldFilename");
String outputSERVERFilename = "";
if (config.existsParam("mixtureServer")) outputSERVERFilename =config.getParam("mixtureServer");
bool initByClient=false; // In this case, the init model is read from the file
if (config.existsParam("initByClient")) initByClient=config.getParam("initByClient").toBool();
bool saveEmptyModel=false;
if (config.existsParam("saveEmptyModel")) saveEmptyModel=config.getParam("saveEmptyModel").toBool();
// label for selected frames - Only the frames associated with this label, in the label files, will be used
bool fixedLabelSelectedFrame=true;
String labelSelectedFrames;
if (config.existsParam("useIdForSelectedFrame")) // the ID of each speaker is used as labelSelectedFrame ?
fixedLabelSelectedFrame=(config.getParam("useIdForSelectedFrame").toBool()==false);
if (fixedLabelSelectedFrame) // the label is decided by the command line and is unique for the run
labelSelectedFrames=config.getParam("labelSelectedFrames");
bool modelData=false;
if (config.existsParam("useModelData")) modelData=config.getParam("useModelData").toBool();
String initModelS=inputWorldFilename;
if (modelData) if (config.existsParam("initModel")) initModelS=config.getParam("initModel"); // Use a specific model for Em init
bool outputAdaptParam=false;
if (config.existsParam("superVectors")) outputAdaptParam=true;
try{
XList inputClientList(inputClientListFileName,config); // read the Id + filenames for each client
XLine * linep;
inputClientList.getLine(0);
MixtureServer ms(config);
StatServer ss(config, ms);
if (verbose) cout << "(TrainTarget) Joint Factor Analysis - Load world model [" << inputWorldFilename<<"]"<<endl;
MixtureGD& world = ms.loadMixtureGD(inputWorldFilename);
if (verbose) cout <<"(TrainTarget) Use["<<initModelS<<"] for initializing EM"<<endl;
//LOAD JFA MAtrices
Matrix<double> U, V;
DoubleVector D;
//Initialise EC matrix
if(config.existsParam("eigenChannelMatrix")){
String uName = config.getParam("matrixFilesPath") + config.getParam("eigenChannelMatrix") + config.getParam("loadMatrixFilesExtension");
U.load (uName, config);
if (verboseLevel >=1) cout << "(TrainTargetJFA) Init EC matrix from "<< config.getParam("eigenChannelMatrix") <<" from EigenChannel Matrix: "<<", rank: ["<<U.rows() << "] sv size: [" << U.cols() <<"]"<<endl;
}
else{
unsigned long sS = world.getVectSize() * world.getDistribCount();
U.setDimensions(1,sS);
U.setAllValues(0.0);
if (verboseLevel >=1) cout << "(TrainTargetJFA) Init EC matrix to 0"<<endl;
}
//Initialise EV matrix
if(config.existsParam("eigenVoiceMatrix")){
String vName = config.getParam("matrixFilesPath") + config.getParam("eigenVoiceMatrix") + config.getParam("loadMatrixFilesExtension");
V.load (vName, config);
if (verboseLevel >=1) cout << "(TrainTargetJFA) Init EV matrix from "<< config.getParam("eigenVoiceMatrix") <<" from EigenVoice Matrix: "<<", rank: ["<<V.rows() << "] sv size: [" << V.cols() <<"]"<<endl;
}
else{
unsigned long sS = world.getVectSize() * world.getDistribCount();
V.setDimensions(1,sS);
V.setAllValues(0.0);
if (verboseLevel >=1) cout << "(TrainTargetJFA) Init EV matrix to 0"<<endl;
}
//Initialise D matrix
if(config.existsParam("DMatrix")){
String dName = config.getParam("matrixFilesPath") + config.getParam("DMatrix") + config.getParam("loadMatrixFilesExtension");
Matrix<double> tmpD(dName, config);
if( (tmpD.rows() != 1) || ( tmpD.cols() != world.getVectSize()*world.getDistribCount() ) ){
throw Exception("Incorrect dimension of D Matrix",__FILE__,__LINE__);
}
else{
D.setSize(world.getVectSize()*world.getDistribCount());
D.setAllValues(0.0);
for(unsigned long i=0; i<world.getVectSize()*world.getDistribCount(); i++){
D[i] = tmpD(0,i);
}
if (verboseLevel >=1) cout << "(TrainTargetJFA) Init D matrix from "<<config.getParam("DMatrix")<<endl;
}
}
else{
unsigned long sS = world.getVectSize() * world.getDistribCount();
D.setSize(sS);
D.setAllValues(0.0);
if (verboseLevel >1) cout << "(TrainTargetJFA) Init D matrix to 0"<<endl;
}
// *********** Target loop *****************
while ((linep=inputClientList.getLine()) != NULL){ // linep gives the XLine with the Id of a given client and the list of files
String *id=linep->getElement(); // Get the Client ID (id)
XLine featureFileListp=linep->getElements(); // Get the list of feature file for the client (end of the line)
if (verbose) cout << "(TrainTarget) Train model ["<<*id<<"]"<<endl;
XList ndx; ndx.addLine() = featureFileListp;
JFAAcc jfaAcc(ndx,config,"TrainTarget");
//Load V, U and D from existing matrices.
//.........这里部分代码省略.........
开发者ID:orsonwang,项目名称:ALIZE-LIA_RAL-extensions,代码行数:101,代码来源:TrainTarget.cpp
示例16: TrainTargetFA
//-----------------------------------------------------------------------------------------------------------------------------------------------------------
int TrainTargetFA(Config& config)
{
String inputClientListFileName = config.getParam("targetIdList");
String inputWorldFilename = config.getParam("inputWorldFilename");
String outputSERVERFilename = "";
if (config.existsParam("mixtureServer")) outputSERVERFilename =config.getParam("mixtureServer");
bool initByClient=false; // In this case, the init model is read from the file
if (config.existsParam("initByClient")) initByClient=config.getParam("initByClient").toBool();
bool saveEmptyModel=false;
if (config.existsParam("saveEmptyModel")) saveEmptyModel=config.getParam("saveEmptyModel").toBool();
// label for selected frames - Only the frames associated with this label, in the label files, will be used
bool fixedLabelSelectedFrame=true;
String labelSelectedFrames;
if (config.existsParam("useIdForSelectedFrame")) // the ID of each speaker is used as labelSelectedFrame ?
fixedLabelSelectedFrame=(config.getParam("useIdForSelectedFrame").toBool()==false);
if (fixedLabelSelectedFrame) // the label is decided by the command line and is unique for the run
labelSelectedFrames=config.getParam("labelSelectedFrames");
bool modelData=false;
if (config.existsParam("useModelData")) modelData=config.getParam("useModelData").toBool();
String initModelS=inputWorldFilename;
if (modelData) if (config.existsParam("initModel")) initModelS=config.getParam("initModel"); // Use a specific model for Em init
bool outputAdaptParam=false;
if (config.existsParam("superVectors")) outputAdaptParam=true;
Matrix <double> ChannelMatrix;
if (verbose) cout<< "EigenMAP and Eigenchannel with [" << config.getParam("initChannelMatrix") << "] of size: [";
ChannelMatrix.load(config.getParam("initChannelMatrix"),config); //get Channel Matrix from args and load in a Matrix object
if (verbose) cout << ChannelMatrix.rows() << "," <<ChannelMatrix.cols() << "]" << endl;
bool varAdapt=false;
if (config.existsParam("FAVarAdapt")) varAdapt=true;
bool saveCompleteServer=false;
try{
XList inputClientList(inputClientListFileName,config); // read the Id + filenames for each client
XLine * linep;
inputClientList.getLine(0);
MixtureServer ms(config);
StatServer ss(config, ms);
if (verbose) cout << "(TrainTarget) Factor Analysis - Load world model [" << inputWorldFilename<<"]"<<endl;
MixtureGD& world = ms.loadMixtureGD(inputWorldFilename);
if (verbose) cout <<"(TrainTarget) Use["<<initModelS<<"] for initializing EM"<<endl;
// *********** Target loop *****************
while ((linep=inputClientList.getLine()) != NULL){ // linep gives the XLine with the Id of a given client and the list of files
String *id=linep->getElement(); // Get the Client ID (id)
XLine featureFileListp=linep->getElements(); // Get the list of feature file for the client (end of the line)
if (verbose) cout << "(TrainTarget) Train model ["<<*id<<"]"<<endl;
FeatureServer fs(config,featureFileListp); // Reading the features (from several files)
SegServer segmentsServer; // Create the segment server for managing the segments/clusters
LabelServer labelServer; // Create the lable server, for indexing the segments/clusters
initializeClusters(featureFileListp,segmentsServer,labelServer,config); // Reading the segmentation files for each feature input file
verifyClusterFile(segmentsServer,fs,config); // Verify if the segments ending before the end of the feature files...
MixtureGD & adaptedMixture = ms.duplicateMixture(world,DUPL_DISTRIB); // Creating final as a copy of the world model
MixtureGD & clientMixture= ms.duplicateMixture(world,DUPL_DISTRIB);
long codeSelectedFrame=labelServer.getLabelIndexByString(labelSelectedFrames); // Get the index of the cluster with in interest audio segments
if (codeSelectedFrame==-1){ // No data for this model !!!!!!!!!!!!!!
cout << " WARNING - NO DATA FOR TRAINING ["<<*id<<"]";
if (saveEmptyModel){
cout <<" World model is returned"<<endl; // In this case, the client model is the world model
if (verbose) cout << "Save client model ["<<*id<<"]" << endl;
adaptedMixture.save(*id, config); // Save the client model
}
}
else{
SegCluster& selectedSegments=segmentsServer.getCluster(codeSelectedFrame); // Gives the cluster of the selected/used segments
/// **** Factor Analysis Stuff
XList faNdx;
faNdx.addLine()=featureFileListp;
FactorAnalysisStat FA(faNdx,fs,config); // give all features to FA stats
//FA.computeAndAccumulateGeneralFAStats(selectedSegments,fs,config);
for(int i=0;i<config.getParam("nbTrainIt").toLong();i++){
if (verbose) cout << "------ Iteration ["<<i<<"] ------"<<endl;
FA.computeAndAccumulateGeneralFAStats(selectedSegments,fs,config);
/*if (!varAdapt) FA.getTrueSpeakerModel(clientMixture,linep->getElement(1));
else FA.getFactorAnalysisModel(clientMixture,linep->getElement(1));
if (verbose) cout << "LLK for model["<<*id<<"] at it["<<i-1<<"]="<<FA.getLLK(selectedSegments,clientMixture,fs,config) << endl; */
FA.estimateAndInverseL(config);
FA.substractSpeakerStats();
FA.getXEstimate();
FA.substractChannelStats();
FA.getYEstimate();
}
MixtureGD & sessionMixture= ms.duplicateMixture(world,DUPL_DISTRIB);
bool saveSessionModel=false;
if (config.existsParam("saveSessionModel")) saveSessionModel=true;
if (saveSessionModel) FA.getSessionModel(sessionMixture,linep->getElement(1));
if (!varAdapt) FA.getTrueSpeakerModel(clientMixture,linep->getElement(1)); // basically compute M_s_h=M+Dy_s and get a model
else FA.getFactorAnalysisModel(clientMixture,linep->getElement(1)); // get FA variance adapted model
if (verbose) cout << "Final LLK for model["<<*id<<"]="<<FA.getLLK(selectedSegments,clientMixture,fs,config) << endl;
/// **** End of FA
if (!outputAdaptParam) {
if (verbose) cout << "Save client model ["<<*id<<"]" << endl;
clientMixture.save(*id, config); // Save the client model
if (saveSessionModel) {
String sessionfile=*id+".session";
if (verbose) cout << "Save session model ["<<sessionfile<<"]" << endl;
sessionMixture.save(sessionfile,config);
//.........这里部分代码省略.........
开发者ID:orsonwang,项目名称:ALIZE-LIA_RAL-extensions,
|
请发表评论