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

📄 batchmoderecognizer.java

📁 It is the Speech recognition software. It is platform independent. To execute the source code,
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                }                return "";           }            public String getHelp() {                return "list active components";            }        });	ci.add("show", new CommandInterface() {	     public String execute(CommandInterpreter ci, String[] args) {                 if (args.length < 2) {                    cm.showConfig();                 } else {                     for (int i = 1; i < args.length; i++) {                        String name = args[i];                        cm.showConfig(name);                     }                }                return "";           }            public String getHelp() {                return "show component configuration";            }        });	ci.add("edit", new CommandInterface() {	     public String execute(CommandInterpreter ci, String[] args) {                 if (args.length != 2) {                    ci.putResponse("Usage: edit component");                 } else {                    cm.editConfig(args[1]);                }                return "";           }            public String getHelp() {                return "edit a  component's configuration";            }        });	ci.add("save", new CommandInterface() {	     public String execute(CommandInterpreter ci, String[] args) {                 if (args.length != 2) {                    ci.putResponse("Usage: save filename.xml");                 } else {                    try {                         cm.save(new File(args[1]));                    } catch (IOException ioe) {                        ci.putResponse("Can't save, " + ioe);                    }                }                return "";           }            public String getHelp() {                return "save configuration to a file";            }        });	ci.add("set", new CommandInterface() {	     public String execute(CommandInterpreter ci, String[] args) {                 if (args.length != 4) {                    ci.putResponse("Usage: set component property value");                 } else {                    try {                        cm.setProperty(args[1], args[2], args[3]);                    } catch (PropertyException pe) {                        ci.putResponse(pe.toString());                    }                }                return "";           }            public String getHelp() {                return "set component property to a given value";            }        });	ci.add("recognize", new CommandInterface() {	     public String execute(CommandInterpreter ci, String[] args) {                 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 result = recognizer.recognize(transcript);                    } catch (IOException io) {                        ci.putResponse("I/O error during decoding: " +                            io.getMessage());                    }                }                return "";           }            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) {                 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 result = recognizer.recognize(transcript);                    } catch (IOException io) {                        ci.putResponse("I/O error during decoding: " +                            io.getMessage());                    }                }                return "";           }            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) {                 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 result = recognizer.recognize(transcript);                        }                    } catch (IOException io) {                        ci.putResponse("I/O error during decoding: " +                            io.getMessage());                    }                }                return "";           }            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) {                 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 result = recognizer.recognize(transcript);                        }                    } catch (IOException io) {                        ci.putResponse("I/O error during decoding: " +                            io.getMessage());                    }                }                return "";           }            public String getHelp() {                return "recognize all of the remaining batch items";            }        });	ci.add("batchReset", new CommandInterface() {	     public String execute(CommandInterpreter ci, String[] args) {                 if (args.length != 1) {                    ci.putResponse("Usage: batchReset");                 } else {                    try {                        batchManager.start();                    } catch (IOException ioe) {                        ci.putResponse("trouble reseting batch");                    }                }                return "";           }           public String getHelp() {               return "reset the batch to the beginning";           }        });	ci.add("batchLoad", new CommandInterface() {	     public String execute(CommandInterpreter ci, String[] args) {                 if (args.length != 2) {                    ci.putResponse("Usage: batchReset batchfile");                 } else {                    try {                        setBatchFile(args[1]);                    } catch (IOException ioe) {                        ci.putResponse("Can't load " + args[1] + " " + ioe);                    }                }                return "";           }           public String getHelp() {               return "reset the batch to the beginning";           }        });    }    public void shell(String batchfile) {        try {            CommandInterpreter ci = new CommandInterpreter();            ci.setPrompt("s4> ");             addCommands(ci);            setBatchFile(batchfile);            recognizer.allocate();            ci.run();            batchManager.stop();            if (recognizer.getState() == RecognizerState.READY) {                recognizer.deallocate();            }        } catch (IOException io) {            logger.severe("I/O error during decoding: " + io.getMessage());        }    }    /**     * Main method of this BatchDecoder.     *      * @param argv     *                argv[0] : config.xml argv[1] : a file listing     *                all the audio files to decode     */    public static void main(String[] argv) {        if (argv.length < 2) {            System.out.println(                    "Usage: BatchDecoder propertiesFile batchFile [-shell]");            System.exit(1);        }        String cmFile = argv[0];        String batchFile = argv[1];        ConfigurationManager cm;        BatchModeRecognizer bmr = null;        BatchModeRecognizer recognizer;        try {            URL url = new File(cmFile).toURI().toURL();            cm = new ConfigurationManager(url);            bmr = (BatchModeRecognizer) cm.lookup("batch");        } catch (IOException ioe) {            System.err.println("I/O error during initialization: \n   " + ioe);            return;        } catch (InstantiationException e) {            System.err.println("Error during initialization: \n  " + e);            return;        } catch (PropertyException e) {            System.err.println("Error during initialization: \n  " + e);            return;        }        if (bmr == null) {            System.err.println("Can't find batchModeRecognizer in " + cmFile);            return;        }        if (argv.length >= 3 && argv[2].equals("-shell")) {            bmr.shell(batchFile);        } else {            bmr.decode(batchFile);        }    }}

⌨️ 快捷键说明

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