当前位置: 首页>>代码示例>>C++>>正文


C++ Alignment::getFrames方法代码示例

本文整理汇总了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 << ")";
}
开发者ID:nlphacker,项目名称:bavieca,代码行数:57,代码来源:FMLLREstimator.cpp

示例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);
	}
}
开发者ID:atk-,项目名称:bavieca-0014,代码行数:55,代码来源:MLLRManager.cpp


注:本文中的Alignment::getFrames方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。