Sphinx-4 JSGF Demo |
This is a simple command line program that demonstrates how to swap
between multiple JSGF grammars .
Check if the bin
directory already has the
JSGFDemo.jar
file. If not, type the following in the top level directory:
ant -find demo.xml
First make sure that you have JSAPI setup correctly. Then, to run the demo, type:
sphinx4> java -mx200m -jar bin/JSGFDemo.jar
NOTE:
lib/sphinx4.jar
is built. If not, go to the top level
directory and type: ant
When the program runs, you will be presented with a series of command
menues that can be spoken. The first menu contains a set of movie
titles that you can 'watch', the second menu contains a set of
newspapers that you can 'read', the third menu contains a set of books
that you can 'read', and finally the last menu contains a set of songs
that you can 'listen' to. Note that this is just a demonstration of
the speech technology. This demo will not actually allow you to
'watch' a movie, 'read' a book or 'listen to music'
Here is a sample run. The spoken commands are
highlighed in green.
JSGF Demo Version 1.0 Loading recognizer ... Ready ====== movies ====== Speak one of: go to the next menu watch a beautiful mind watch american beauty watch brave heart watch chariots of fire watch chicago watch dances with wolves watch driving miss daisy watch finding nemo watch gladiator watch lord of the rings watch ordinary people watch out of africa watch platoon watch rain man watch shakespeare in love watch spider man watch terms of endearment watch the empire strikes back watch the italian job watch the matrix watch the silence of the lambs watch titanic watch two thousand one a space odyssey watch unforgiven ============================ watch lord of the rings watch the empire strikes back go to the next menu ====== news ====== Speak one of: go to the next menu read planet sun read the boston globe read the chicago tribune read the daily mirror read the guardian read the los angeles times read the nashua telegraph read the new york times read the san francisco chronicle read the san jose mercury news read the sun read the wall street journal read the washington post ============================ read the new york times read the nashua telegraph go to the next menu ====== books ====== Speak one of: go to the next menu read angels and demons read code and other laws of cyber space read eats shoots and leaves read effective java read harry potter and the goblet of fire read spoken language processing read the curious incident of the dog in the night time read the da vinci code read the future of ideas read the lord of the rings read the time travelers wife ============================ read harry potter and the goblet of fire read the curious incident of the dog in the night time go to the next menu ====== music ====== Speak one of: go to the next menu listen to as time goes by listen to diamonds are a girl's best friend listen to moon river listen to mrs robinson listen to over the rainbow listen to singing in the rain listen to staying alive listen to the man that got away listen to the sound of music listen to the way we were listen to when you wish upon a star listen to white christmas ============================ listen to the sound of music listen to over the rainbow go to the next menu Done. Cleaning up ... Goodbye.
URL url = JSGFDemo.class.getResource("jsgf.config.xml"); ConfigurationManager cm = new ConfigurationManager(url); jsgfGrammarManager = (JSGFGrammar) cm.lookup("jsgfGrammar");
private void loadAndRecognize(String grammarName) throws IOException, GrammarException { jsgfGrammarManager.loadJSGF(grammarName); dumpSampleSentences(grammarName); recognizeAndReport(); }
private void addRule(RuleGrammar ruleGrammar, String ruleName, String jsgf) throws GrammarException { Rule newRule = ruleGrammar.ruleForJSGF(jsgf); ruleGrammar.setRule(ruleName, newRule, true); ruleGrammar.setEnabled(ruleName, true); }