我正在尝试构建一个使用基本语音识别的程序。在尝试查找"识别器时,我遇到了一个问题。 voice.config.xml文件中的组件。我使用Sphinx4相对较新,所以这可能是一个非常简单的错误。我花了好几个小时试图找到它,因此我将非常感谢一个解释良好且详细的回复。
这是我将用于翻译输入的方法。
public static void translate() {
URL url = S2T.class.getResource("voice.config.xml");
ConfigurationManager cm = new ConfigurationManager(url);
PropertySheet ps = cm.getPropertySheet("voice.config.xml");
Microphone microphone = (Microphone) cm.lookup("microphone");
Recognizer recognizer = (Recognizer) cm.lookup("recognizer");
recognizer.allocate();
if(microphone.startRecording()) {
while(true) {
Result result = recognizer.recognize();
String resultText = result.getBestResultNoFiller();
System.out.println("You said: " + resultText);
}
}
}
当我从另一个类调用该方法时,这是我得到的错误:
Exception in thread "main" java.lang.IncompatibleClassChangeError: Found class edu.cmu.sphinx.util.props.PropertySheet, but interface was expected
at edu.cmu.sphinx.model.acoustic.WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.Model.newProperties(Model.java:158)
at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:505)
at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:287)
at edu.cmu.sphinx.linguist.flat.FlatLinguist.setupAcousticModel(FlatLinguist.java:278)
at edu.cmu.sphinx.linguist.flat.FlatLinguist.newProperties(FlatLinguist.java:244)
at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:505)
at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:287)
at edu.cmu.sphinx.decoder.search.SimpleBreadthFirstSearchManager.newProperties(SimpleBreadthFirstSearchManager.java:182)
at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:505)
at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:287)
at edu.cmu.sphinx.decoder.AbstractDecoder.newProperties(AbstractDecoder.java:65)
at edu.cmu.sphinx.decoder.Decoder.newProperties(Decoder.java:37)
at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:505)
at edu.cmu.sphinx.util.props.PropertySheet.getComponent(PropertySheet.java:287)
at edu.cmu.sphinx.recognizer.Recognizer.newProperties(Recognizer.java:90)
at edu.cmu.sphinx.util.props.PropertySheet.getOwner(PropertySheet.java:505)
at edu.cmu.sphinx.util.props.ConfigurationManager.lookup(ConfigurationManager.java:161)
at LukeTrujillo.CAB.Voice.S2T.translate(S2T.java:25)
at LukeTrujllo.CAB.Main.Main.main(Main.java:14)
这是我这个类所在的包的当前构建路径:
LukeTrujillo/CAB/Voice/
- Main.java
- S2T.gram
- voice.config.xml
- voice.Manifest
Classpath中的Sphinx JAR:
答案 0 :(得分:0)
您使用的是过时的sphinx4与不兼容的版本。你可以找到一个教程 和CMUSphinx网站上的最新下载: