我一直在用 Java 制作一个语音识别程序,只是为了看看它是如何工作的。直到一天前,一切都运行良好。我不知道发生了什么,因为我没有更改代码中的任何内容。
由于它出现了一个词法错误,我想我只需要粘贴我的语法文件。
控制.gram:
#JSGF V1.0;
grammar controls;
public <intro> = "Computer";
public <statement> = <open> | <ignore>;
public <open> = "open" ("chrome" | "word");
public <navigate> = "navigate" "to" (("face" book") | ("stack" "overflow"));
public <ignore> = ("don't" "worry") | ("never" "mind");
public <thanks> = "thanks";
错误日志:
Exception in thread "main" edu.cmu.sphinx.jsgf.parser.TokenMgrError: Lexical error at line 11, column 77. Encountered: "\r" (13), after : "\"));"
at edu.cmu.sphinx.jsgf.parser.JSGFParserTokenManager.getNextToken(JSGFParserTokenManager.java:1197)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.jj_ntk(JSGFParser.java:1012)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.item(JSGFParser.java:643)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.sequence(JSGFParser.java:568)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.alternatives(JSGFParser.java:484)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.item(JSGFParser.java:676)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.sequence(JSGFParser.java:568)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.alternatives(JSGFParser.java:484)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.item(JSGFParser.java:676)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.sequence(JSGFParser.java:568)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.alternatives(JSGFParser.java:484)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.RuleDeclaration(JSGFParser.java:450)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.GrammarUnit(JSGFParser.java:313)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.newGrammarFromJSGF(JSGFParser.java:128)
at edu.cmu.sphinx.jsgf.parser.JSGFParser.newGrammarFromJSGF(JSGFParser.java:241)
at edu.cmu.sphinx.jsgf.JSGFGrammar.loadNamedGrammar(JSGFGrammar.java:697)
at edu.cmu.sphinx.jsgf.JSGFGrammar.commitChanges(JSGFGrammar.java:613)
at edu.cmu.sphinx.jsgf.JSGFGrammar.createGrammar(JSGFGrammar.java:300)
at edu.cmu.sphinx.linguist.language.grammar.Grammar.allocate(Grammar.java:116)
at edu.cmu.sphinx.linguist.flat.FlatLinguist.allocate(FlatLinguist.java:300)
at edu.cmu.sphinx.decoder.search.SimpleBreadthFirstSearchManager.allocate(SimpleBreadthFirstSearchManager.java:646)
at edu.cmu.sphinx.decoder.AbstractDecoder.allocate(AbstractDecoder.java:87)
at edu.cmu.sphinx.recognizer.Recognizer.allocate(Recognizer.java:168)
at [MY PACKAGE].Utils.<init>(Utils.java:23)
at [MY PACKAGE].Launcher.<clinit>(Launcher.java:8)
我尝试删除所有空白字符,将其编码为 ANSI、UTF(带和不带 BOM)。所有这些都无济于事......
有人能帮我一下吗?