Exemple #1
0
        /** Constructs a phone loop search graph. */
        public PhoneLoopSearchGraph(SentenceHMMState initState, AcousticModel model, float logPhoneInsertionProbability)
        {
            this.inititalState = initState;
            this.model         = model;
            this.logPhoneInsertionProbability = logPhoneInsertionProbability;
            existingStates = new Dictionary <string, SearchState>();
            firstState     = new UnknownWordState();
            SentenceHMMState branchState = new BranchOutState(firstState);

            attachState(firstState, branchState, logOne, logOne);

            SentenceHMMState lastState = new LoopBackState(firstState);

            //lastState.setFinalState(true);
            //attachState(lastState, branchState, LogMath.getLogZero(),
            //		LogMath.getLogZero());
            attachState(lastState, inititalState, logOne, logOne);

            for (java.util.Iterator i = model.getContextIndependentUnitIterator(); i.hasNext();)
            {
                Unit      unit      = (Unit)i.next();
                UnitState unitState = new UnitState(unit, HMMPosition.UNDEFINED);

                // attach unit state to the branch out state
                attachState(branchState, unitState, logOne, logPhoneInsertionProbability);

                HMM hmm = model.lookupNearestHMM
                              (unitState.getUnit(), unitState.getPosition(), false);
                HMMState      initialState = hmm.getInitialState();
                HMMStateState hmmTree      = new HMMStateState(unitState, initialState);
                addStateToCache(hmmTree);

                // attach first HMM state to the unit state
                attachState(unitState, hmmTree, logOne, logOne);

                // expand the HMM tree
                HMMStateState finalState = expandHMMTree(unitState, hmmTree);

                // attach final state of HMM tree to the loopback state
                attachState(finalState, lastState, logOne, logOne);
            }
        }