Menu

Run Sphinx4 decoding using JSGF grammar in batch mode

Long Qin
2014-11-13
2014-11-13
  • Long Qin

    Long Qin - 2014-11-13

    Hello everyone,

    I want to run sphinx4 in batch mode while using the JSGF grammar. For instance, I have 5 utterances, utt_1, utt_2, utt_3, utt_4, utt_5. And for each utterance, I have write a grammar file, such as grammar_1, grammar_2, grammar_3, grammar_4, grammar_5. How to config sphinx and/or write code to decode utt_x using grammar_x?

    I googled, but most things I found refer to the old JSGF demo, which doesn't seem to work now. My current configuration is to use flatLinguist with jsgfGrammar. Should I skip "grammarName" in the config.xml file in my case? Then how to load the grammar for each utterance?

    Thanks!
    Long

     
  • Long Qin

    Long Qin - 2014-11-13

    OK, it seems that I can create a default/dummy grammar file in YOUR_PATH/default/gram.gram. Then for each utterance, I can do

    JSGFGrammar jsgfGrammarManager = (JSGFGrammar) config.lookup("jsgfGrammar");
    jsgfGrammarManager.loadJSGF("grammar_x");
    
    StreamDataSource dataSource = (StreamDataSource) config.lookup("dataSource");
    dataSource.setInputStream(new URL("file:utt_x").openStream());
    
    Result result = recognizer.recognize();
    

    All these need to happen after recognizer.allocate();

     

Log in to post a comment.