// on a segment void featureMapping(MixtureServer & ms, FeatureServer & fs,Seg * seg,Config &config) { unsigned long begin=seg->begin()+fs.getFirstFeatureIndexOfASource(seg->sourceName()); // Idx of the first frame of the current file in the feature server fs.seekFeature(begin); Feature f; for (unsigned long idxFrame=0;idxFrame<seg->length();idxFrame++){ // for all the features of the segment fs.readFeature(f,0); featureMapping(ms,f,config); fs.writeFeature(f); } }
// ---------------------------------------------------------------------------------------------------------- // Feature Warping giving a source(tab of histo, one by coeff) and a target distribution // for a segment and cluster (segment is the minimum time unit to perform this) void computeWarp(Histo *histoT,Histo &destH,FeatureServer & fs,unsigned long begin, unsigned long length,Config &config) { unsigned long vectsize=fs.getVectSize(); // Get the vect size (number of coeff) Feature f; fs.seekFeature(begin); for (unsigned long idxFrame=0;idxFrame<length;idxFrame++){ // for all the features of the segment fs.readFeature(f,0); // Get the feature; for (unsigned int i = 0; i < vectsize; i++){ // For each coeff f[i]=warping(f[i],histoT[i],destH); // Apply the warping function } fs.writeFeature(f); } }
// ---------------------------------------------------------------------------------------------------------- // Feature Mean subtraction and Cov reduction for a segment and cluster (segment is considerred to be the minimum time unit to perform this). void computeZeroOne(const DoubleVector &featureMean,const DoubleVector &featureStd,FeatureServer & fs,unsigned long begin, unsigned long length,Config &config) { unsigned long vectsize=fs.getVectSize(); // Get the vect size (number of coeff) Feature f; fs.seekFeature(begin); for (unsigned long idxFrame=0;idxFrame<length;idxFrame++){ // for all the features of the segment fs.readFeature(f,0); // Get the feature; for (unsigned int i = 0; i < vectsize; i++) { // For each coeff f[i]=(f[i]-featureMean[i])/featureStd[i]; // Apply the 0 mean 1 cov normalisation } fs.writeFeature(f); } }
/// Normalize features with a smooth mixture transformation o't=ot-sum(P(c|ot)Uc.x) void FactorAnalysisStat::normalizeFeatures(SegCluster &selectedSegments,FeatureServer &fs,Config & config){ if (verbose) cout << "(FactorAnalysisStat) Normalize Features" << endl; MixtureGD & clientMixture=_ms.getMixtureGD(1); // copy the UBM mixture unsigned long nt=0; RealVector <double> m_xh_1; m_xh_1.setSize(_supervsize); double *_m_xh_1=m_xh_1.getArray(); Seg *seg; // current selectd segment selectedSegments.rewind(); String currentSource=""; while((seg=selectedSegments.getSeg())!=NULL){ unsigned long begin=seg->begin()+fs.getFirstFeatureIndexOfASource(seg->sourceName()); if (currentSource!=seg->sourceName()) { currentSource=seg->sourceName(); this->getUX(m_xh_1,currentSource); this->getSpeakerModel(clientMixture,currentSource); if (verbose)cout << "Processing speaker["<<currentSource<<"]"<< endl; } fs.seekFeature(begin); Feature f; if (!_topGauss) { for (unsigned long idxFrame=0;idxFrame<seg->length();idxFrame++){ fs.readFeature(f,0); double *ff=f.getDataVector(); double sum=0.0; RealVector <double> P; P.setSize(_mixsize); double *Prob=P.getArray(); for(unsigned long k=0;k<_mixsize;k++) { Prob[k]=clientMixture.weight(k)*clientMixture.getDistrib(k).computeLK(f); sum+=Prob[k]; } for(unsigned long k=0;k<_mixsize;k++) Prob[k]/=sum; for(unsigned long k=0;k<_mixsize;k++) { for (unsigned long i=0;i<_vsize;i++) ff[i]-= Prob[k]*_m_xh_1[k*_vsize+i]; } fs.writeFeature(f); nt++; } } else { throw Exception("no topgauss yet",__FILE__,__LINE__); } } };