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";