Page 173 - The Definitive Guide to Building Java Robots
P. 173

Preston_5564C05.fm  Page 154  Tuesday, September 20, 2005  5:13 AM



                 154    CHAPTER 5  ■  SPEECH



                        Example 5-12. notepad.gram
                        #JSGF V1.0;

                        /**
                         * JSGF Grammar for notepad example
                         */

                        grammar notepad;

                        public <notepad> = (note pad);
                        public <exit> = (exit | good bye | quit);

                            Next, I need to create a class that will use this grammar file to actually launch a program.

                        Code Objective

                        The objective here is to perform basic speech recognition to open notepad, and then exit.

                        Code Discussion
                        After the grammar file, I need to create a configuration file for the recognizer. I used a provided
                        configuration file from one of the examples, but had to make a few modifications to the grammar
                        configuration for my class and my new grammar file. The configuration contains the other
                        following sections:
                            •word recognizer
                            • decoder

                            • linguist
                            •dictionary

                            • acoustic model
                            • unit manager
                            •frontend

                            • monitors
                            • miscellaneous

                            In the following configuration, the dictionary is defined later in the configuration file. This
                        contains all the words the recognizer can find.
   168   169   170   171   172   173   174   175   176   177   178