Package edu.cmu.sphinx.fst

Examples of edu.cmu.sphinx.fst.Fst


     *
     * @return the created fst
     */
    private Fst createFst() {
        TropicalSemiring ts = new TropicalSemiring();
        Fst fst = new Fst(ts);

        State s1 = new State(ts.zero());
        State s2 = new State(ts.zero());
        State s3 = new State(ts.zero());
        State s4 = new State(2.f);

        // State 0
        fst.addState(s1);
        s1.addArc(new Arc(1, 5, 1.f, s2));
        s1.addArc(new Arc(2, 4, 3.f, s2));
        fst.setStart(s1);

        // State 1
        fst.addState(s2);
        s2.addArc(new Arc(3, 3, 7.f, s2));
        s2.addArc(new Arc(4, 2, 5.f, s3));

        // State 2
        fst.addState(s3);
        s3.addArc(new Arc(5, 1, 9.f, s4));

        // State 3
        fst.addState(s4);

        return fst;
    }
View Full Code Here


     *
     * @return the created fst
     */
    private Fst createPi() {
        TropicalSemiring ts = new TropicalSemiring();
        Fst fst = new Fst(ts);
        State s1 = new State(ts.zero());
        State s2 = new State(ts.zero());
        State s3 = new State(ts.zero());
        State s4 = new State(2.f);

        // State 0
        fst.addState(s1);
        s1.addArc(new Arc(1, 1, 1.f, s2));
        s1.addArc(new Arc(2, 2, 3.f, s2));
        fst.setStart(s1);

        // State 1
        fst.addState(s2);
        s2.addArc(new Arc(3, 3, 7.f, s2));
        s2.addArc(new Arc(4, 4, 5.f, s3));

        // State 2
        fst.addState(s3);
        s3.addArc(new Arc(5, 5, 9.f, s4));

        // State 3
        fst.addState(s4);

        return fst;
    }
View Full Code Here

     *
     * @return the created fst
     */
    private Fst createPo() {
        TropicalSemiring ts = new TropicalSemiring();
        Fst fst = new Fst(ts);

        State s1 = new State(ts.zero());
        State s2 = new State(ts.zero());
        State s3 = new State(ts.zero());
        State s4 = new State(2.f);

        // State 0
        fst.addState(s1);
        s1.addArc(new Arc(5, 5, 1.f, s2));
        s1.addArc(new Arc(4, 4, 3.f, s2));
        fst.setStart(s1);

        // State 1
        fst.addState(s2);
        s2.addArc(new Arc(3, 3, 7.f, s2));
        s2.addArc(new Arc(2, 2, 5.f, s3));

        // State 2
        fst.addState(s3);
        s3.addArc(new Arc(1, 1, 9.f, s4));

        // State 3
        fst.addState(s4);

        return fst;
    }
View Full Code Here

    @Test
    public void testProject() {
        System.out.println("Testing Project...");
        // Project on Input label
        Fst fst = createFst();
        Fst p = createPi();
        Project.apply(fst, ProjectType.INPUT);
        Assert.assertTrue(fst.equals(p));

        // Project on Output label
        fst = createFst();
View Full Code Here

         * convert our object to the Sphinx OpenFst data structure
         *
         * @return an edu.cmu.sphinx.fst.Fst built from the XML
         */
        public Fst toFst() {
            Fst openFst = new Fst(ring);
            openFst.setIsyms(inputAlphabet.toSymbols());
            openFst.setOsyms(outputAlphabet.toSymbols());
            openFstStates = new ArrayList<edu.cmu.sphinx.fst.State>(
                    states.size());
            for (State state : states) {
                edu.cmu.sphinx.fst.State openFstState = state
                        .toUnconnectedOpenFstState();
                openFst.addState(openFstState);
                assert openFstState.getId() == state.id;
                openFstStates.add(openFstState);
            }
            openFst.setStart(openFstStates.get(0));
            // second pass (now that all openFst states are created) to add all
            // the openFst arcs
            for (State state : states) {
                state.connectStates(openFstStates);
            }
View Full Code Here

TOP

Related Classes of edu.cmu.sphinx.fst.Fst

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.