edu.cmu.sphinx.jsgf.parser.TokenMgrError: Lexical error at line 8, column 20. Encountered: "\u00ac" (172), after : ""
at edu.cmu.sphinx.jsgf.parser.JSGFParserTokenManager.getNextToken(JSGFParserTokenManager.java:1187)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.jj_ntk(JSGFParser.java:998)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.item(JSGFParser.java:636)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.sequence(JSGFParser.java:559)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.alternatives(JSGFParser.java:473)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.item(JSGFParser.java:669)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.sequence(JSGFParser.java:559)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.alternatives(JSGFParser.java:473)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.RuleDeclaration(JSGFParser.java:438)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.GrammarUnit(JSGFParser.java:299)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.newGrammarFromJSGF(JSGFParser.java:122)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.newGrammarFromJSGF(JSGFParser.java:232)
at edu.cmu.sphinx.jsgf.JSGFGrammar.loadNamedGrammar(JSGFGrammar.java:703)
at edu.cmu.sphinx.jsgf.JSGFGrammar.commitChanges(JSGFGrammar.java:619)
at edu.cmu.sphinx.jsgf.JSGFGrammar.createGrammar(JSGFGrammar.java:303)
at edu.cmu.sphinx.linguist.language.grammar.Grammar.allocate(Grammar.java:112)
at edu.cmu.sphinx.linguist.flat.FlatLinguist.allocate(FlatLinguist.java:264)
at edu.cmu.sphinx.decoder.search.SimpleBreadthFirstSearchManager.allocate(SimpleBreadthFirstSearchManager.java:647)
at edu.cmu.sphinx.decoder.AbstractDecoder.allocate(AbstractDecoder.java:103)
at edu.cmu.sphinx.recognizer.Recognizer.allocate(Recognizer.java:164)
at edu.cmu.sphinx.api.LiveSpeechRecognizer.startRecognition(LiveSpeechRecognizer.java:47)
at com.mycompany.test_speech.Main.microphoneRec(Main.java:62)
at com.mycompany.test_speech.Main.main(Main.java:55)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi
i have below config in code but it return words that is not in this grammer. why?
configuration
.setAcousticModelPath("file:" + ws);
configuration
.setDictionaryPath("file:" + ws1);
configuration
.setLanguageModelPath("file:" + ws2);
configuration.setGrammarPath("file:F:\projects\speech\test_speech\test_speech\src\main\java\com\mycompany\test_speech\hello.gram");
You need configuration.setUseGrammar(true), and there is no need to call setLanguageModelPath if you want to use grammar.
thx for help.
then why this exception is throws?
edu.cmu.sphinx.jsgf.parser.TokenMgrError: Lexical error at line 8, column 20. Encountered: "\u00ac" (172), after : ""
at edu.cmu.sphinx.jsgf.parser.JSGFParserTokenManager.getNextToken(JSGFParserTokenManager.java:1187)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.jj_ntk(JSGFParser.java:998)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.item(JSGFParser.java:636)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.sequence(JSGFParser.java:559)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.alternatives(JSGFParser.java:473)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.item(JSGFParser.java:669)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.sequence(JSGFParser.java:559)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.alternatives(JSGFParser.java:473)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.RuleDeclaration(JSGFParser.java:438)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.GrammarUnit(JSGFParser.java:299)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.newGrammarFromJSGF(JSGFParser.java:122)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.newGrammarFromJSGF(JSGFParser.java:232)
at edu.cmu.sphinx.jsgf.JSGFGrammar.loadNamedGrammar(JSGFGrammar.java:703)
at edu.cmu.sphinx.jsgf.JSGFGrammar.commitChanges(JSGFGrammar.java:619)
at edu.cmu.sphinx.jsgf.JSGFGrammar.createGrammar(JSGFGrammar.java:303)
at edu.cmu.sphinx.linguist.language.grammar.Grammar.allocate(Grammar.java:112)
at edu.cmu.sphinx.linguist.flat.FlatLinguist.allocate(FlatLinguist.java:264)
at edu.cmu.sphinx.decoder.search.SimpleBreadthFirstSearchManager.allocate(SimpleBreadthFirstSearchManager.java:647)
at edu.cmu.sphinx.decoder.AbstractDecoder.allocate(AbstractDecoder.java:103)
at edu.cmu.sphinx.recognizer.Recognizer.allocate(Recognizer.java:164)
at edu.cmu.sphinx.api.LiveSpeechRecognizer.startRecognition(LiveSpeechRecognizer.java:47)
at com.mycompany.test_speech.Main.microphoneRec(Main.java:62)
at com.mycompany.test_speech.Main.main(Main.java:55)
Something wrong with your grammar. You can share it to get futher help.
grammer file attached.
Try to add -Dfile.encoding=utf-8 to jvm options.
very thx. solved.