У меня есть проблема с Sphinx 4 в java. Я Реализован код ниже:Sphinx 4 - Консоль
package test.ionut;
import edu.cmu.sphinx.frontend.util.Microphone;
import edu.cmu.sphinx.recognizer.Recognizer;
import edu.cmu.sphinx.result.Result;
import edu.cmu.sphinx.util.props.ConfigurationManager;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
ConfigurationManager manager;
if(args.length > 0){
manager=new ConfigurationManager(args[0]);
}else{
manager=new ConfigurationManager(Test.class.getResource("test.config.xml"));
}
Recognizer recognizer=(Recognizer)manager.lookup("recognizer");
recognizer.allocate();
Microphone mic=(Microphone)manager.lookup("microphone");
if(!mic.startRecording()){
System.out.println("Mic not identified.");
recognizer.deallocate();
System.out.println(1);
System.out.println("Say: (Good morning | Hello | Hi | Welcome) (Dipayan | Paul | Philip | Rita | Will)");
while(true){
System.out.println("Start speaking. Press Ctrl-C to quit.\n");
Result result = recognizer.recognize();
if(result != null) {
String resultText = result.getBestFinalResultNoFiller();
// System.out.println((new StringBuilder()).append("You said: ").append(resultText).append('\n').toString());
System.out.println("You said: "+resultText+"...");
} else {
System.out.println("I can't hear what you said.\n");
}
}
}
}
}
this is the grammar file:
***#JSGF V1.0;***
***grammar hello;***
***public <greet>= (Good morning | Hello | Hi | Welcome) (Paul | Philip | Rita | Will);***
and in the xml file i have modified so that the program knows what to do with the gram file.
Bellow is the part of the code where i modified the xml:
<!-- ******************************************************** -->
<!-- The Grammar configuration -->
<!-- ******************************************************** -->
<component name="jsgfGrammar" type="edu.cmu.sphinx.jsgf.JSGFGrammar">
<property name="dictionary" value="dictionary"/>
<property name="grammarLocation"
value="resource:/test/ionut/"/>
<property name="grammarName" value="mydict"/>
<property name="logMath" value="logMath"/>
</component>
Any help is appreciated.
Проблема заключается в том, что, когда я компиляции кода, я не получаю сообщение об ошибке, но консоль ничего, даже не первый отпечаток не показывают. Если я изменю файл графа, добавив слово, которое не находится в словаре, а затем нажмите «Бег», консоль покажет мне ошибку, что слово является известным словом в словаре. После удаления слова, нажмите пробег и снова: консоль ничего мне не показывает. Также я добавил дополнительную память кучи с аргументом -mx256m.
Я пробовал целый день с этим, так как я хочу реализовать слова с моего собственного языка с помощью sphinx 4. Но сейчас я просто делаю тест, привыкший к нему.
Извините за плохое редактирование, не знаю, почему вопрос был опубликован следующим образом. Если вы прочитаете текст в области прокрутки, вы поймете, что я объясняю. Опять же, извините ... – Myself