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

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


     * @return the overall acoustic score
     */
    private float calculateScores(int index) {
        float logScore;
        // Find the HMM state for this node
        SenoneHMMState state = (SenoneHMMState) graph.getNode(index).getObject();
        if ((state != null) && (state.isEmitting())) {
            // Compute the scores for each mixture component in this state
            componentScores = state.calculateComponentScore(curFeature);
            // Compute the overall score for this state
            logScore = state.getScore(curFeature);
            // For CI models, for now, we only try to use mixtures
            // with one component
            assert componentScores.length == 1;
        } else {
            componentScores = null;
View Full Code Here


            // Treat dummy node (and initial and final nodes) the same
            // 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;
                }
                // Adds the alpha and transition from the previous
View Full Code Here

TOP

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

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.