Package edu.cmu.sphinx.api

Examples of edu.cmu.sphinx.api.SpeechResult


        InputStream stream = TranscriberDemo.class.getResourceAsStream(
                "/edu/cmu/sphinx/demo/aligner/10001-90210-01803.wav");
       
        // Simple recognition with generic model
        recognizer.startRecognition(stream);
        SpeechResult result;
        while ((result = recognizer.getResult()) != null) {
       
            System.out.format("Hypothesis: %s\n",
                              result.getHypothesis());
                             
            System.out.println("List of recognized words and their times:");
            for (WordResult r : result.getWords()) {
          System.out.println(r);
            }

            System.out.println("Best 3 hypothesis:");           
            for (String s : result.getNbest(3))
                System.out.println(s);

            System.out.println("Lattice contains " + result.getLattice().getNodes().size() + " nodes");
        }
        recognizer.stopRecognition();
   
       
        // Live adaptation to speaker with speaker profiles
        stream = TranscriberDemo.class.getResourceAsStream(
                "/edu/cmu/sphinx/demo/aligner/10001-90210-01803.wav");
       
        // Stats class is used to collect speaker-specific data
        Stats stats = recognizer.createStats(1);
        recognizer.startRecognition(stream);
        while ((result = recognizer.getResult()) != null) {
            stats.collect(result);
        }
        recognizer.stopRecognition();
       
        // Transform represents the speech profile
        Transform transform = stats.createTransform();
        recognizer.setTransform(transform);
       
        // Decode again with updated transform
        stream = TranscriberDemo.class.getResourceAsStream(
                "/edu/cmu/sphinx/demo/aligner/10001-90210-01803.wav");
        recognizer.startRecognition(stream);
        while ((result = recognizer.getResult()) != null) {
            System.out.format("Hypothesis: %s\n",
                    result.getHypothesis());
        }
        recognizer.stopRecognition();
       
    }
View Full Code Here


        StreamSpeechRecognizer recognizer = new StreamSpeechRecognizer(
                configuration);

        TimeFrame t;
        SpeechResult result;

        for (SpeakerCluster spk : speakers) {
            Stats stats = recognizer.createStats(1);
            ArrayList<Segment> segments = spk.getSpeakerIntervals();

            for (Segment s : segments) {
                long startTime = s.getStartTime();
                long endTime = s.getStartTime() + s.getLength();
                t = new TimeFrame(startTime, endTime);

                recognizer.startRecognition(url.openStream(), t);
                while ((result = recognizer.getResult()) != null) {
                    stats.collect(result);
                }
                recognizer.stopRecognition();
            }

            Transform profile;
            // Create the Transformation
            profile = stats.createTransform();
            recognizer.setTransform(profile);

            for (Segment seg : segments) {
                long startTime = seg.getStartTime();
                long endTime = seg.getStartTime() + seg.getLength();
                t = new TimeFrame(startTime, endTime);

                // Decode again with updated SpeakerProfile
                recognizer.startRecognition(url.openStream(), t);
                while ((result = recognizer.getResult()) != null) {
                    System.out.format("Hypothesis: %s\n",
                            result.getHypothesis());
                }
                recognizer.stopRecognition();
            }
        }
    }
View Full Code Here

TOP

Related Classes of edu.cmu.sphinx.api.SpeechResult

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.