question: public void htsMaximumLikelihoodParameterGeneration ( HTSUttModel um , final HMMData htsData ) throws Exception { CartTreeSet ms = htsData . getCartTreeSet ( ) ; if ( htsData . getPdfMgcStream ( ) != null ) mcepPst = new HTSPStream ( ms . getMcepVsize ( ) , um . getTotalFrame ( ) , HMMData . FeatureType . MGC , htsData . getMaxMgcGvIter ( ) ) ; if ( htsData . getPdfLf0Stream ( ) != null ) lf0Pst = new HTSPStream ( ms . getLf0Stream ( ) , um . getLf0Frame ( ) , HMMData . FeatureType . LF0 , htsData . getMaxLf0GvIter ( ) ) ; if ( htsData . getPdfStrStream ( ) != null ) strPst = new HTSPStream ( ms . getStrVsize ( ) , um . getTotalFrame ( ) , HMMData . FeatureType . STR , htsData . getMaxStrGvIter ( ) ) ; if ( htsData . getPdfMagStream ( ) != null ) magPst = new HTSPStream ( ms . getMagVsize ( ) , um . getTotalFrame ( ) , HMMData . FeatureType . MAG , htsData . getMaxMagGvIter ( ) ) ; int lf0Frame = 0 ; int uttFrame = 0 ; voiced = new boolean [ um . getTotalFrame ( ) ] ; int msNumStates = ms . getNumStates ( ) ; int totalFrames = um . getTotalFrame ( ) ; for ( int i = 0 ; i < um . getNumUttModel ( ) ; i ++ ) { HTSModel m = um . getUttModel ( i ) ; int numVoicedInModel = 0 ; for ( int state = 0 ; state < msNumStates ; state ++ ) { Arrays . fill ( voiced , uttFrame , uttFrame += m . getDur ( state ) , m . getVoiced ( state ) ) ; if ( m . getVoiced ( state ) ) lf0Frame += m . getDur ( state ) ; } } Log . d ( Mary . LOG , "utteranceFrame=" + uttFrame + " lf0frame=" + lf0Frame ) ; uttFrame = 0 ; lf0Frame = 0 ; for ( int i = 0 ; i < um . getNumUttModel ( ) ; i ++ ) { HTSModel m = um . getUttModel ( i ) ; boolean gvSwitch = m . getGvSwitch ( ) ; for ( int state = 0 ; state < msNumStates ; state ++ ) { for ( int frame = 0 ; frame < m . getDur ( state ) ; frame ++ ) { if ( mcepPst != null ) { mcepPst . setMseq ( uttFrame , m . getMean ( FeatureType . MGC , state ) ) ; mcepPst . setVseq ( uttFrame , m . getVariance ( FeatureType . MGC , state ) ) ; if ( ! gvSwitch ) mcepPst . setGvSwitch ( uttFrame , false ) ; } if ( strPst != null ) { strPst . setMseq ( uttFrame , m . getMean ( FeatureType . STR , state ) ) ; strPst . setVseq ( uttFrame , m . getVariance ( FeatureType . STR , state ) ) ; if ( ! gvSwitch ) strPst . setGvSwitch ( uttFrame , false ) ; } if ( magPst != null ) { magPst . setMseq ( uttFrame , m . getMean ( FeatureType . MAG , state ) ) ; magPst . setVseq ( uttFrame , m . getVariance ( FeatureType . MAG , state ) ) ; if ( ! gvSwitch ) magPst . setGvSwitch ( uttFrame , false ) ; } if ( lf0Pst != null && ! htsData . getUseAcousticModels ( ) ) { for ( int k = 0 ; k < ms . getLf0Stream ( ) ; k ++ ) { boolean nobound = true ; for ( int n = lf0Pst . getDWLeftBoundary ( k ) ; n <= lf0Pst . getDWRightBoundary ( k ) ; n ++ ) if ( ( uttFrame + n ) <= 0 || totalFrames <= ( uttFrame + n ) ) nobound = false ; else nobound = ( nobound && voiced [ uttFrame + n ] ) ; if ( voiced [ uttFrame ] ) { lf0Pst . setMseq ( lf0Frame , k , m . getLf0Mean ( state , k ) ) ; if ( nobound || k == 0 ) lf0Pst . setIvseq ( lf0Frame , k , finv ( m . getLf0Variance ( state , k ) ) ) ; else lf0Pst . setIvseq ( lf0Frame , k , 0.0 ) ; } } } if ( voiced [ uttFrame ] ) { if ( ! gvSwitch ) lf0Pst . setGvSwitch ( lf0Frame , false ) ; lf0Frame ++ ; } uttFrame ++ ; } } } GVModelSet gvms = htsData . getGVModelSet ( ) ; if ( mcepPst != null ) mcepPst . fixDynFeatOnBoundaries ( ) ; if ( strPst != null ) strPst . fixDynFeatOnBoundaries ( ) ; if ( magPst != null ) magPst . fixDynFeatOnBoundaries ( ) ; if ( mcepPst != null ) { Log . i ( Mary . LOG , "Parameter generation for MGC: " ) ; if ( htsData . getUseGV ( ) && ( htsData . getPdfMgcGVStream ( ) != null ) ) mcepPst . setGvMeanVar ( gvms . getGVmeanMgc ( ) , gvms . getGVcovInvMgc ( ) ) ; mcepPst . mlpg ( htsData , htsData . getUseGV ( ) ) ; } if ( htsData . getUseAcousticModels ( ) ) loadMaryXmlF0 ( um , htsData ) ; else if ( lf0Pst != null ) { Log . i ( Mary . LOG , "Parameter generation for LF0: " ) ; if ( htsData . getUseGV ( ) && ( htsData . getPdfLf0GVStream ( ) != null ) ) lf0Pst . setGvMeanVar ( gvms . getGVmeanLf0 ( ) , gvms . getGVcovInvLf0 ( ) ) ; lf0Pst . mlpg ( htsData , htsData . getUseGV ( ) ) ; setRealisedF0 ( lf0Pst , um , msNumStates ) ; } boolean useGV = false ; if ( strPst != null ) { Log . d ( Mary . LOG , "Parameter generation for STR " ) ; if ( htsData . getUseGV ( ) && ( htsData . getPdfStrGVStream ( ) != null ) ) { useGV = true ; strPst . setGvMeanVar ( gvms . getGVmeanStr ( ) , gvms . getGVcovInvStr ( ) ) ; } strPst . mlpg ( htsData , useGV ) ; } useGV = false ; if ( magPst != null ) { Log . i ( Mary . LOG , "Parameter generation for MAG " ) ; if ( htsData . getUseGV ( ) && ( htsData . getPdfMagGVStream ( ) != null ) ) { useGV = true ; magPst . setGvMeanVar ( gvms . getGVmeanMag ( ) , gvms . getGVcovInvMag ( ) ) ; } magPst . mlpg ( htsData , useGV ) ; } }
target:  HTS maximum likelihood parameter generation