I have been making a speech recognition program in Java just to see how it works. It was all working completely fine up until a day ago. I have no idea what happened as I didn't change anything in my code.
As it is coming up with a lexical error I think I only need to paste my grammar file.
controls.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";
Error log:
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)
I have tried removing all Whitespace characters, encoding it in ANSI, UTF (with and without BOM). All of which have been to no avail...
Can anyone help me here?
You have a missing quote:
public = "navigate" "to" (("face" "
book") | ("stack" "overflow"));
That should fix it :-)