package sphinxtest;
导入edu.cmu.sphinx.api.Configuration;
导入edu.cmu.sphinx.api.LiveSpeechRecognizer;
导入edu.cmu.sphinx.api.SpeechResult;
import java.io.IOException;
公共课Sphinxtest {
/**
* @param args the command line arguments
* @throws java.io.IOException
*/
public static void main(String[] args) throws IOException {
System.out.println("running");
Configuration config = new Configuration();
config.setAcousticModelPath("resource:/edu/cmu/sphinx/models/en-us/en-us");
config.setDictionaryPath("C:\\Users\\sys\\Desktop\\3481.dic");
config.setLanguageModelPath("C:\\Users\\sys\\Desktop\\3481.dic");
LiveSpeechRecognizer rec = new LiveSpeechRecognizer (config);
rec.startRecognition(true);
SpeechResult spinput ;
while ( ( spinput = rec.getResult() ) != null) {
String command = spinput.getHypothesis();
if (command.equalsIgnoreCase("click")){
System.out.println("click command recieved");
}
}
}
}``