Example #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);
        }
Example #2
0
 /**
  * Creates the CIPhoneLoop with the given acoustic model and phone insertion probability
  *
  * @param model                        the acoustic model
  * @param logPhoneInsertionProbability the insertion probability
  */
 public PhoneLoopCI(AcousticModel model,
                    float logPhoneInsertionProbability,
                    SentenceHMMState initialState)
 {
     this.model = model;
     this.logPhoneInsertionProbability =
         logPhoneInsertionProbability;
     this.inititalState = initialState;
 }
Example #3
0
        protected void attachState(SentenceHMMState prevState,
                                   SentenceHMMState nextState,
                                   float logLanguageProbability,
                                   float logInsertionProbability)
        {
            SentenceHMMStateArc arc = new SentenceHMMStateArc
                                          (nextState,
                                          logLanguageProbability,
                                          logInsertionProbability);

            prevState.connect(arc);
        }
Example #4
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);
            }
        }
Example #5
0
 public BranchOutState(SentenceHMMState parent) : base("BranchOutState", parent, 0)
 {
 }
Example #6
0
 public LoopBackState(SentenceHMMState parent) : base("CIPhonesLoopBackState", parent, 0)
 {
 }
Example #7
0
 /**
  * Adds the given state to the cache of states
  *
  * @param state the state to add
  */
 protected void addStateToCache(SentenceHMMState state)
 {
     existingStates.Add(state.getSignature(), state);
 }
Example #8
0
 /**
  * Checks to see if a state that matches the given state already exists
  *
  * @param state the state to check
  * @return true if a state with an identical signature already exists.
  */
 private SentenceHMMState getExistingState(SentenceHMMState state)
 {
     return((SentenceHMMState)existingStates[state.getSignature()]);
 }
 internal BranchOutState(SentenceHMMState parent) : base("BranchOutState", parent, 0)
 {
 }