⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lextreelinguist.java

📁 It is the Speech recognition software. It is platform independent. To execute the source code,
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
         *          * @param endNode         *                the unit node         * @param previous         *                the previous state         *          * @return the search state         */        SearchStateArc createEndUnitArc(EndNode endNode, LexTreeState previous) {            float probability = getUnigramSmear(endNode)                    + previous.getSmearTerm();            float arcProbability = probability - previous.getSmearProb();            float insertionProbability = calculateInsertionProbability(endNode);            return new LexTreeEndUnitState(endNode, getWordHistory(), previous                    .getSmearTerm(), probability, arcProbability,                    insertionProbability);        }        /**         * Returns the string representation of this object         *          * @return the string representation         */        public String toString() {            return "lt-" + node + " " + getProbability() + "{" + wordSequence                    + "}";        }        /**         * Returns a pretty version of the string representation for this         * object         *          * @return a pretty string         */        public String toPrettyString() {            return toString();        }        /**         * Gets the successor arcs for this state from the cache         *         * @return the next set of arcs for this state, or null if         * none can be found or if caching is disabled.         */        SearchStateArc[] getCachedArcs() {            if (cacheEnabled) {                SearchStateArc[] arcs = (SearchStateArc[]) arcCache.get(this);                if (arcs != null) {                    cacheHits++;                }                if (++cacheTrys % 1000000 == 0) {                    System.out.println("Hits: " + cacheHits                             + " of " + cacheTrys + " " +                             ((float) cacheHits) / cacheTrys * 100f);                }                return arcs;            } else {                return null;            }        }        /**         * Puts the set of arcs into the cache         *         * @param arcs the arcs to cache.         */        void putCachedArcs(SearchStateArc[] arcs) {            if (cacheEnabled) {                arcCache.put(this, arcs);            }        }        abstract public int getOrder();    }    /**     * Represents a unit in the search space     */    public class LexTreeEndUnitState extends LexTreeState            implements UnitSearchState {        float logLanguageProbability;        float logInsertionProbability;        /**         * Constructs a LexTreeUnitState         *          * @param wordSequence         *                the history of words         */        LexTreeEndUnitState(EndNode endNode, WordSequence wordSequence,                float smearTerm, float smearProb, float languageProbability,                float insertionProbability) {            super(endNode, wordSequence, smearTerm, smearProb);            logLanguageProbability = languageProbability;            logInsertionProbability = insertionProbability;            // System.out.println("LTEUS " + logLanguageProbability + " " +            // logInsertionProbability);        }        /**         * Returns the base unit assciated with this state         *          * @return the base unit         */        public Unit getUnit() {            return getEndNode().getBaseUnit();        }        /**         * Generate a hashcode for an object         *          * @return the hashcode         */        public int hashCode() {            return super.hashCode() * 17 + 423;        }        /**         * Gets the acoustic probability of entering this state         *          * @return the log probability         */        public float getInsertionProbability() {            return logInsertionProbability;        }        /**         * Gets the language probability of entering this state         *          * @return the log probability         */        public float getLanguageProbability() {            return logLanguageProbability;        }        /**         * Determines if the given object is equal to this object         *          * @param o         *                the object to test         * @return <code>true</code> if the object is equal to this         */        public boolean equals(Object o) {            if (o == this) {                return true;            } else if (o instanceof LexTreeEndUnitState) {                LexTreeEndUnitState other = (LexTreeEndUnitState) o;                return super.equals(o);            } else {                return false;            }        }        /**         * Returns the unit node for this state         *          * @return the unit node         */        private EndNode getEndNode() {            return (EndNode) getNode();        }        /**         * Returns the list of successors to this state         *          * @return a list of SearchState objects         */        public SearchStateArc[] getSuccessors() {            SearchStateArc[] arcs = getCachedArcs();            if (arcs == null) {                HMMNode[] nodes = getHMMNodes(getEndNode());                arcs = new SearchStateArc[nodes.length];                if (generateUnitStates) {                    for (int i = 0; i < nodes.length; i++) {                        arcs[i] = new LexTreeUnitState(nodes[i],                             getWordHistory(), getSmearTerm(),                             getSmearProb(), logOne, logOne,                            this.getNode());                    }                } else {                    for (int i = 0; i < nodes.length; i++) {                        HMM hmm = nodes[i].getHMM();                        arcs[i] = new LexTreeHMMState(nodes[i],                                 getWordHistory(), getSmearTerm(),                                 getSmearProb(), hmm.getInitialState(),                                 logOne, logOne, logOne, this.getNode());                    }                }                putCachedArcs(arcs);            }            return arcs;        }        public String toString() {            return super.toString() + " EndUnit";        }        public int getOrder() {            return 3;        }    }    /**     * Represents a unit in the search space     */    public class LexTreeUnitState extends LexTreeState            implements UnitSearchState {        private float logInsertionProbability;        private float logLanguageProbability;        private Node parentNode = null;        private int hashCode = -1;        /**         * Constructs a LexTreeUnitState         *          * @param wordSequence         *                the history of words         */        LexTreeUnitState(HMMNode hmmNode, WordSequence wordSequence,                float smearTerm, float smearProb, float languageProbability,                float insertionProbability) {            this(hmmNode, wordSequence, smearTerm, smearProb,                    languageProbability, insertionProbability, null);        }        /**         * Constructs a LexTreeUnitState         *          * @param wordSequence         *                the history of words         */        LexTreeUnitState(HMMNode hmmNode, WordSequence wordSequence,                float smearTerm, float smearProb, float languageProbability,                float insertionProbability, Node parentNode) {            super(hmmNode, wordSequence, smearTerm, smearProb);            this.logInsertionProbability = insertionProbability;            this.logLanguageProbability = languageProbability;            this.parentNode = parentNode;        }        /**         * Returns the base unit assciated with this state         *          * @return the base unit         */        public Unit getUnit() {            return getHMMNode().getBaseUnit();        }        /**         * Generate a hashcode for an object         *          * @return the hashcode         */        public int hashCode() {            if (hashCode == -1) {                hashCode = super.hashCode() * 17 + 421;                if (parentNode != null) {                    hashCode *= 432;                    hashCode += parentNode.hashCode();                }            }            return hashCode;        }        /**         * Determines if the given object is equal to this object         *          * @param o         *                the object to test         * @return <code>true</code> if the object is equal to this         */        public boolean equals(Object o) {            if (o == this) {                return true;            } else if (o instanceof LexTreeUnitState) {                LexTreeUnitState other = (LexTreeUnitState) o;                return super.equals(o) && parentNode == other.parentNode;            } else {                return false;            }        }        /**         * Returns the unit node for this state         *          * @return the unit node         */        private HMMNode getHMMNode() {            return (HMMNode) getNode();        }        /**         * Returns the list of successors to this state         *          * @return a list of SearchState objects         */        public SearchStateArc[] getSuccessors() {            SearchStateArc[] arcs = new SearchStateArc[1];            HMM hmm = getHMMNode().getHMM();            arcs[0] = new LexTreeHMMState(getHMMNode(), getWordHistory(),                    getSmearTerm(), getSmearProb(), hmm.getInitialState(),                    logOne, logOne, logOne, parentNode);            return arcs;        }        public String toString() {            return super.toString() + " unit";        }        /**         * Gets the acoustic probability of entering this state         *          * @return the log probability         */        public float getInsertionProbability() {            return logInsertionProbability;        }        /**         * Gets the language probability of entering this state         *          * @return the log probability         */        public float getLanguageProbability() {            return logLanguageProbability;        }        public int getOrder() {            return 4;        }    }    /**     * Represents a HMM state in the search space     */    public class LexTreeHMMState extends LexTreeState implements HMMSearchState {        private HMMState hmmState;        private float logLanguageProbability;        private float logInsertionProbability;        private float logAcousticProbability;        private Node parentNode;        int hashCode = -1;        /**         * Constructs a LexTreeHMMState         *          * @param hmmNode         *                the hmm state associated with this unit         *          * @param wordSequence         *                the word history         *          * @param languageProbability         *                the probability of the transition         * @param insertionProbability         *                the probability of the transition         * @param acousticProbability         *                the probability of the transition occuring         */        LexTreeHMMState(HMMNode hmmNode, WordSequence wordSequence,                float smearTerm, float smearProb, HMMState hmmState,                float languageProbability, float insertionProbability,                float acousticProbability, Node parentNode) {            super(hmmNode, wordSequence, smearTerm, smearProb);            this.hmmState = hmmState;            this.parentNode = parentNode;            this.logLanguageProbability = languageProbability;            this.logInsertionProbability = insertionProbability;            this.logAcousticProbability = acousticProbability;        }        /**         * Gets the ID for this state         *          * @return the ID         */        public String getSignature() {            return super.getSignature() + "-HMM-" + hmmState.getState();        }        /**         * returns the hmm state associated with this state         *          * @return the hmm state         */        public HMMState getHMMState() {            return hmmState;        }        /**         * Generate a hashcode for an object         *          * @return the hashcode         */        public int hashCode() {            if (hashCode == -1) {                hashCode = super.hashCode() * 29 + (hmmState.getState() + 1);                if (parentNode != null) {                    hashCode *= 377;                    hashCode += parentNode.hashCode();                }            }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -