示例#1
0
        /**
         * Expands the given hmm state tree
         * package edu.cmu.sphinx.linguist.KWSFlatLinguist;
         *
         * public class PhoneLoopCI {
         *
         * }
         *
         * @param parent the parent of the tree
         * @param tree   the tree to expand
         * @return the final state in the tree
         */
        protected HMMStateState expandHMMTree(UnitState parent,
                                              HMMStateState tree)
        {
            HMMStateState retState = tree;

            foreach (HMMStateArc arc in tree.getHMMState().getSuccessors())
            {
                HMMStateState newState;
                if (arc.getHMMState().isEmitting())
                {
                    newState = new HMMStateState
                                   (parent, arc.getHMMState());
                }
                else
                {
                    newState = new NonEmittingHMMState
                                   (parent, arc.getHMMState());
                }
                SentenceHMMState existingState = getExistingState(newState);
                float            logProb       = arc.getLogProbability();
                if (existingState != null)
                {
                    attachState(tree, existingState, logOne, logProb);
                }
                else
                {
                    attachState(tree, newState, logOne, logProb);
                    addStateToCache(newState);
                    retState = expandHMMTree(parent, newState);
                }
            }
            return(retState);
        }
示例#2
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);
            }
        }