Java 如何添加用户在Sphinx 4(语音识别)中选择的关键字?
我想知道如何使用GRAM文件在Java中使用sphinx 4向语音识别添加自定义关键字 比如:public=(set-song) 我怎样才能做到在“设置歌曲”之后,用户可以说任何他想说的话,而它仍然会被解析Java 如何添加用户在Sphinx 4(语音识别)中选择的关键字?,java,speech-recognition,sphinx4,Java,Speech Recognition,Sphinx4,我想知道如何使用GRAM文件在Java中使用sphinx 4向语音识别添加自定义关键字 比如:public=(set-song) 我怎样才能做到在“设置歌曲”之后,用户可以说任何他想说的话,而它仍然会被解析 URL url = LulzSpeech.class.getResource("lulzspeech.config.xml");; System.out.println("Loading input..."); ConfigurationM
URL url = LulzSpeech.class.getResource("lulzspeech.config.xml");;
System.out.println("Loading input...");
ConfigurationManager cm = new ConfigurationManager(url);
Recognizer recognizer = (Recognizer) cm.lookup("recognizer");
Microphone microphone = (Microphone) cm.lookup("microphone");
recognizer.allocate();
if (microphone.startRecording()) {
System.out.println("Loading input completed, mic working, ready!");
try{
while (true) {
Thread.sleep(50);
Result result = recognizer.recognize();
if (result != null)
if(result.getBestFinalResultNoFiller().toLowerCase().contains(MainLulz.programName.toLowerCase()))
MainLulz.mainVoiceHandler.handleInput(result.getBestFinalResultNoFiller());
}
}catch(Exception e){
e.printStackTrace();
}
} else {
System.out.println("Cannot start microphone.");
recognizer.deallocate();
System.exit(1);
}
} catch (IOException e) {
System.err.println("Problem when loading LulzSpeech input: " + e);
e.printStackTrace();
} catch (PropertyException e) {
System.err.println("Problem configuring LulzSpeech input: " + e);
e.printStackTrace();
} catch (InstantiationException e) {
System.err.println("Problem creating LulzSpeech input: " + e);
e.printStackTrace();
}
当前版本的Sphinx-4中未实现关键字检测功能。您无法轻松检测关键字。您所说的“用户可以说他想要的任何内容,但它仍然会被解析”是什么意思?请您提供一个示例,例如:“查找文件”,然后用户可以说他想要的任何内容,它会找到该文件。就像“查找文件数据点文本”一样,但我不需要将系统中的每个文件都放入GRAM文件中。容易吗?那么,你知道有什么方法可以做到这一点(容易还是不容易)?