Package edu.cmu.sphinx.result

Examples of edu.cmu.sphinx.result.Result


    Timer t = new Timer(2500, new ActionListener() {

      @Override
      public void actionPerformed(ActionEvent e) {
        System.out.println("start speaking");
        Result result = recognizer.recognize();
        if (result != null) {
          String resultText = result.getBestFinalResultNoFiller();
          System.out.println("You said: " + resultText + '\n');
        } else {
          System.out.println("I can't hear what you said.\n");
        }
      }
View Full Code Here


      System.out.println("speak!");
    }
  }

  public void finish() {
    Result result = recognizer.recognize();
    if (result != null) {
      String resultText = result.getBestResultNoFiller();
      System.out.println("You said: " + resultText + '\n');
      FusionManager.getInstance().postIncantation(resultText);
    } else {
      System.out.println("I can't hear what you said.\n");
    }
View Full Code Here

    }

    @Override
    protected void onRun() {
        while (true) {
            Result result = recognizer.recognize();
            if (result != null) {
                String resultText = result.getBestFinalResultNoFiller();
                setDescription("You said: " + resultText);
                if (!resultText.trim().isEmpty()) {
                    SpeechEvent event = new SpeechEvent(this, resultText);
                    Freedomotic.sendEvent(event);
                }
View Full Code Here

      ArrayList<Long> endTimeAnnot = new ArrayList<Long>();
     
      StringBuffer document = new StringBuffer();
      Iterator audioIt = aJCas.getAnnotationIndex(Audio.type).iterator();
      Audio audio = (Audio) audioIt.next();
      Result result;
     
  //    getContext().getLogger().log("CF File is " + ConfigFile);
     
  //    if(audioIt.hasNext())
     
View Full Code Here

                }

                context.setSpeechSource(audioUrl.openStream(), frame);

                List<WordResult> hypothesis = new ArrayList<WordResult>();
                Result result;
                while (null != (result = recognizer.recognize())) {
                    hypothesis.addAll(result.getTimedBestResult(false));
                }

                if (i == 0) {
                    if (hypothesis.size() > 0) {
                        lastFrame = hypothesis.get(hypothesis.size() - 1)
View Full Code Here

     * @param nFrames the number of frames to recognize
     * @return the current result or null if there is no Result (due to the lack of frames to recognize)
     */
    public Result recognize(int nFrames) {
        boolean done = false;
        Result result = null;
        streamEnd = false;
        for (int i = 0; i < nFrames && !done; i++) {
            done = recognize();
        }

        // generate a new temporary result if the current token is based on a final search state
        // remark: the first check for not null is necessary in cases that the search space does not contain scoreable tokens.
        if (activeList.getBestToken() != null) {
            // to make the current result as correct as possible we undo the last search graph expansion here
            ActiveList fixedList = undoLastGrowStep();
             
            // Now create the result using the fixed active-list.
            if (!streamEnd)
               result =
                    new Result(fixedList, resultList, currentFrameNumber, done);
        }

        if (showTokenCount) {
            showTokenCount();
        }
View Full Code Here

    /**
     * Returns result of the recognition.
     */
    public SpeechResult getResult() {
        Result result = recognizer.recognize();
        return null == result ? null : new SpeechResult(result);
    }
View Full Code Here

                    + batchManager.getFilename());

            while (count < utteranceId &&
                    (batchItem = batchManager.getNextItem()) != null) {
                setInputStream(batchItem.getFilename());
                Result result = recognizer.recognize(batchItem.getTranscript());
                logger.info("File  : " + batchItem.getFilename());
                logger.info("Result: " + result);
                count++;
            }
            batchManager.stop();
View Full Code Here

                return "set component property to a given value";
            }
        });
        ci.add("recognize", new CommandInterface() {
            public String execute(CommandInterpreter ci, String[] args) {
                Result result = null;

                if (args.length < 2) {
                    ci.putResponse("Usage: recognize audio [transcript]");
                } else {
                    String audioFile = args[1];
                    String transcript = null;
                    if (args.length > 2) {
                        transcript = args[2];
                    }

                    try {
                        setInputStream(audioFile);
                        result = recognizer.recognize(transcript);
                    } catch (IOException io) {
                        ci.putResponse("I/O error during decoding: " +
                                io.getMessage());
                    }
                }

                return result != null ? result.getBestResultNoFiller() : "";
            }


            public String getHelp() {
                return "perform recognition on the given audio";
            }
        });
        ci.addAlias("recognize", "rec");

        ci.add("statsReset", new CommandInterface() {
            public String execute(CommandInterpreter ci, String[] args) {
                if (args.length != 1) {
                    ci.putResponse("Usage: statsReset");
                } else {
                    recognizer.resetMonitors();
                }
                return "";
            }


            public String getHelp() {
                return "resets gathered statistics";
            }
        });

        ci.add("batchRecognize", new CommandInterface() {
            public String execute(CommandInterpreter ci, String[] args) {
                Result result = null;

                if (args.length != 1) {
                    ci.putResponse("Usage: batchRecognize");
                } else {

                    try {
                        if (curBatchItem == null) {
                            batchManager.start();
                            curBatchItem = batchManager.getNextItem();
                        }
                        String audioFile = curBatchItem.getFilename();
                        String transcript = curBatchItem.getTranscript();
                        setInputStream(audioFile);
                        result = recognizer.recognize(transcript);
                    } catch (IOException io) {
                        ci.putResponse("I/O error during decoding: " +
                                io.getMessage());
                    }
                }
                return result != null ? result.getBestResultNoFiller() : "";
            }


            public String getHelp() {
                return "perform recognition on the current batch item";
            }
        });
        ci.addAlias("batchRecognize", "br");

        ci.add("batchNext", new CommandInterface() {
            public String execute(CommandInterpreter ci, String[] args) {
                Result result = null;

                if (args.length != 1 && args.length != 2) {
                    ci.putResponse("Usage: batchNext [norec]");
                } else {
                    try {

                        // if we don't have a batch item, start (or
                        // start over)

                        if (curBatchItem == null) {
                            batchManager.start();
                        }
                        curBatchItem = batchManager.getNextItem();

                        // if we reach the end, just loop back and
                        // start over.

                        if (curBatchItem == null) {
                            batchManager.start();
                            curBatchItem = batchManager.getNextItem();
                        }

                        String audioFile = curBatchItem.getFilename();
                        String transcript = curBatchItem.getTranscript();
                        if (args.length == 2) {
                            ci.putResponse("Skipping: " + transcript);
                        } else {
                            setInputStream(audioFile);
                            result = recognizer.recognize(transcript);
                        }
                    } catch (IOException io) {
                        ci.putResponse("I/O error during decoding: " +
                                io.getMessage());
                    }
                }
                return result != null ? result.getBestResultNoFiller() : "";
            }


            public String getHelp() {
                return "advance the batch and perform recognition";
            }
        });
        ci.addAlias("batchNext", "bn");

        ci.add("batchAll", new CommandInterface() {
            public String execute(CommandInterpreter ci, String[] args) {
                Result result = null;

                if (args.length != 1) {
                    ci.putResponse("Usage: batchAll");
                } else {
                    try {
                        if (curBatchItem == null) {
                            batchManager.start();
                        }

                        while (true) {
                            curBatchItem = batchManager.getNextItem();
                            // if we reach the end  bail out

                            if (curBatchItem == null) {
                                return "";
                            }
                            String audioFile = curBatchItem.getFilename();
                            String transcript = curBatchItem.getTranscript();
                            setInputStream(audioFile);
                            result = recognizer.recognize(transcript);
                        }
                    } catch (IOException io) {
                        ci.putResponse("I/O error during decoding: " +
                                io.getMessage());
                    }
                }
                return result != null ? result.getBestResultNoFiller() : "";
            }


            public String getHelp() {
                return "recognize all of the remaining batch items";
View Full Code Here

        recognizer.deallocate();
    }


    public Result recognize() throws IOException {
        Result result = null;
        BatchItem batchItem;
        if (count < utteranceId &&
                (batchItem = batchManager.getNextItem()) != null) {
            setInputStream(batchItem.getFilename());
            result = recognizer.recognize(batchItem.getTranscript());
View Full Code Here

TOP

Related Classes of edu.cmu.sphinx.result.Result

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.