本文整理汇总了C++中Alignment::getFrames方法的典型用法代码示例。如果您正苦于以下问题:C++ Alignment::getFrames方法的具体用法?C++ Alignment::getFrames怎么用?C++ Alignment::getFrames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Alignment
的用法示例。
在下文中一共展示了Alignment::getFrames方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: feedAdaptationData
// feed adaptation data from a batch file containing entries (rawFile alignmentFile)
void FMLLREstimator::feedAdaptationData(const char *strBatchFile, const char *strAlignmentFormat,
double *dLikelihood) {
BatchFile batchFile(strBatchFile,"features|alignment");
batchFile.load();
for(unsigned int i=0 ; i < batchFile.size() ; ++i) {
//for(int i=0 ; i < 5 ; ++i) {
// load the alignment
Alignment *alignment = NULL;
if (strcmp(strAlignmentFormat,"text") == 0) {
AlignmentFile alignmentFile(m_phoneSet);
VPhoneAlignment *vPhoneAlignment = alignmentFile.load(batchFile.getField(i,"alignment"));
assert(vPhoneAlignment);
alignment = AlignmentFile::toAlignment(m_phoneSet,m_hmmManager,vPhoneAlignment);
AlignmentFile::destroyPhoneAlignment(vPhoneAlignment);
} else {
alignment = Alignment::load(batchFile.getField(i,"alignment"),NULL);
assert(alignment);
}
// load the feature vectors
FeatureFile featureFile(batchFile.getField(i,"features"),MODE_READ);
featureFile.load();
Matrix<float> *mFeatures = featureFile.getFeatureVectors();
// load and apply the transform
/*
Transform *transform = new Transform();
transform->load("/data/daniel/tasks/wsj/experiments/may16th_2013_CMNUtterance/5/fmllr1/transforms/440m.fmllr.bin");
Matrix<float> *mFeaturesX = transform->apply(*mFeatures);
mFeatures = mFeaturesX;
delete transform;
*/
// check consistency
if (mFeatures->getRows() != alignment->getFrames()) {
BVC_ERROR << "inconsistent number of feature vectors / alignment file";
}
// accumulate adaptation data
double dLikelihoodAlignment = 0.0;
feedAdaptationData(*mFeatures,alignment,&dLikelihoodAlignment);
BVC_VERB << "loaded file: " << batchFile.getField(i,"alignment") << " likelihood: " << FLT(10,2)
<< dLikelihoodAlignment << " (" << mFeatures->getRows() << "frames)";
*dLikelihood += dLikelihoodAlignment;
// clean-up
delete alignment;
delete mFeatures;
}
double dLikelihoodFrame = (*dLikelihood)/m_fOccupancyTotal;
BVC_VERB << "total likelihood: " << FLT(20,6) << *dLikelihood << " (likelihood per frame: "
<< FLT(8,4) << dLikelihoodFrame << ")";
}
示例2: feedAdaptationData
// feed adaptation data from a batch file containing entries (rawFile alignmentFile)
void MLLRManager::feedAdaptationData(const char *strBatchFile, const char *strAlignmentFormat,
double *dLikelihood, bool bVerbose) {
BatchFile batchFile(strBatchFile,"features|alignment");
batchFile.load();
*dLikelihood = 0.0;
for(unsigned int i=0 ; i < batchFile.size() ; ++i) {
// load the alignment
Alignment *alignment = NULL;
// text format
if (strcmp(strAlignmentFormat,"text") == 0) {
AlignmentFile alignmentFile(m_phoneSet,NULL);
VPhoneAlignment *vPhoneAlignment = alignmentFile.load(batchFile.getField(i,"alignment"));
assert(vPhoneAlignment);
alignment = AlignmentFile::toAlignment(m_phoneSet,m_hmmManager,vPhoneAlignment);
AlignmentFile::destroyPhoneAlignment(vPhoneAlignment);
}
// binary format
else {
alignment = Alignment::load(batchFile.getField(i,"alignment"),NULL);
assert(alignment);
}
// load the feature vectors
FeatureFile featureFile(batchFile.getField(i,"features"),MODE_READ);
featureFile.load();
unsigned int iFeatureVectors = 0;
float *fFeatures = featureFile.getFeatureVectors(&iFeatureVectors);
// check consistency
if (iFeatureVectors != alignment->getFrames()) {
BVC_ERROR << "inconsistent number of feature vectors / alignment file";
}
// accumulate adaptation data
double dLikelihoodAlignment = 0.0;
feedAdaptationData(fFeatures,iFeatureVectors,alignment,&dLikelihoodAlignment);
if (bVerbose) {
printf("loaded file: %s likelihood: %12.2f\n",batchFile.getField(i,"alignment"),dLikelihoodAlignment);
}
*dLikelihood += dLikelihoodAlignment;
// clean-up
delete alignment;
delete [] fFeatures;
}
if (bVerbose) {
printf("total likelihood: %14.4f\n",*dLikelihood);
}
}