Package edu.cmu.sphinx.linguist.acoustic.tiedstate

Examples of edu.cmu.sphinx.linguist.acoustic.tiedstate.SenoneHMM


        // For dummy state, the state is a null pointer
        if ((state != null) && (state.isEmitting())) {
            // get the index and the HMM for this HMMState
            int stateIndex = state.getState();
            SenoneHMM hmm = (SenoneHMM) state.getHMM();
            // Get the senone sequence associated with this HMM
            SenoneSequence ss = hmm.getSenoneSequence();
            // Get the senone associated with this HMMState, located
            // in the stateIndex-th position in the senone sequence
            senone = ss.getSenones()[stateIndex];
            // After this, we need to go to the senone pool to find
            // out the senone id... Or maybe we can operate directly
View Full Code Here


            // as non-emitting
            if (!node.isType("STATE")) {
                continue;
            }
            SenoneHMMState state = (SenoneHMMState) node.getObject();
            SenoneHMM hmm = (SenoneHMM) state.getHMM();
            if (!state.isEmitting()) {
                continue;
            }
            // Initialize the current frame probability with 0.0f, log scale
            probCurrentFrame[indexNode] = LogMath.LOG_ZERO;
            for (node.startIncomingEdgeIterator();
                 node.hasMoreIncomingEdges();) {
                // Finds out what the previous node and previous state are
                Node previousNode = node.nextIncomingEdge().getSource();
                int indexPreviousNode = graph.indexOf(previousNode);
                HMMState previousState = (HMMState) previousNode.getObject();
                float logTransitionProbability;
                // previous state could be have an associated hmm state...
                if (previousState != null) {
                    // Make sure that the transition happened from a state
                    // that either is in the same model, or was a
                    // non-emitting state
                    assert ((!previousState.isEmitting()) ||
                            (previousState.getHMM() == hmm));
                    if (!previousState.isEmitting()) {
                        logTransitionProbability = 0.0f;
                    } else {
                        logTransitionProbability =
                                hmm.getTransitionProbability(
                                        previousState.getState(),
                                        state.getState());
                    }
                } else {
                    // Previous state is a dummy state or beginning of
                    // utterance.
                    logTransitionProbability = 0.0f;
                }
                // Adds the alpha and transition from the previous
                // state into the current alpha
                probCurrentFrame[indexNode] =
                        logMath.addAsLinear(probCurrentFrame[indexNode],
                                probPreviousFrame[indexPreviousNode] +
                                        logTransitionProbability);
                // System.out.println("State= " + indexNode + " curr "
                // + probCurrentFrame[indexNode] + " prev " +
                // probPreviousFrame[indexNode] + " trans " +
                // logTransitionProbability);
            }
            // Finally, multiply by this state's output probability for the
            // current Feature (add in log scale)
            probCurrentFrame[indexNode] += outputProbs[indexNode];
            // System.out.println("State= " + indexNode + " alpha= " +
            // probCurrentFrame[indexNode]);
            score[indexNode].setAlpha(probCurrentFrame[indexNode]);
        }

        // Finally, the non-emitting states
        for (int indexNode = 0; indexNode < graph.size(); indexNode++) {
            Node node = graph.getNode(indexNode);
            HMMState state = null;
            SenoneHMM hmm = null;
            if (node.isType("STATE")) {
                state = (HMMState) node.getObject();
                hmm = (SenoneHMM) state.getHMM();
                if (state.isEmitting()) {
                    continue;
                }
            } else if (graph.isInitialNode(node)) {
                score[indexNode].setAlpha(LogMath.LOG_ZERO);
                probCurrentFrame[indexNode] = LogMath.LOG_ZERO;
                continue;
            }
            // Initialize the current frame probability 0.0f, log scale
            probCurrentFrame[indexNode] = LogMath.LOG_ZERO;
            for (node.startIncomingEdgeIterator();
                 node.hasMoreIncomingEdges();) {
                float logTransitionProbability;
                // Finds out what the previous node and previous state are
                Node previousNode = node.nextIncomingEdge().getSource();
                int indexPreviousNode = graph.indexOf(previousNode);
                if (previousNode.isType("STATE")) {
                    HMMState previousState =
                            (HMMState) previousNode.getObject();
                    // Make sure that the transition happened from a
                    // state that either is in the same model, or was
                    // a non-emitting state
                    assert ((!previousState.isEmitting()) ||
                            (previousState.getHMM() == hmm));
                    if (!previousState.isEmitting()) {
                        logTransitionProbability = 0.0f;
                    } else {
                        // previousState == state
                        logTransitionProbability =
                                hmm.getTransitionProbability(
                                        previousState.getState(),
                                        state.getState());
                    }
                } else {
                    logTransitionProbability = 0.0f;
View Full Code Here

            // as non-emitting
            if (!node.isType("STATE")) {
                continue;
            }
            HMMState state = (HMMState) node.getObject();
            SenoneHMM hmm = (SenoneHMM) state.getHMM();
            if (!state.isEmitting()) {
                continue;
            }
            // Initialize the current frame probability with log
            // probability of log(0f)
            probCurrentFrame[indexNode] = LogMath.LOG_ZERO;
            for (node.startOutgoingEdgeIterator();
                 node.hasMoreOutgoingEdges();) {
                float logTransitionProbability;
                // Finds out what the next node and next state are
                Node nextNode = node.nextOutgoingEdge().getDestination();
                int indexNextNode = graph.indexOf(nextNode);
                HMMState nextState = (HMMState) nextNode.getObject();
                if (nextState != null) {
                    // Make sure that the transition happened to a
                    // non-emitting state, or to the same model
                    assert ((!nextState.isEmitting()) ||
                            (nextState.getHMM() == hmm));
                    if (nextState.getHMM() != hmm) {
                        logTransitionProbability = 0.0f;
                    } else {
                        logTransitionProbability =
                                hmm.getTransitionProbability(state.getState(),
                                        nextState.getState());
                    }
                } else {
                    // Next state is a dummy state or beginning of
                    // utterance.
View Full Code Here

TOP

Related Classes of edu.cmu.sphinx.linguist.acoustic.tiedstate.SenoneHMM

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.