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

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



                                                                                  CHAPTER 5  ■  SPEECH   163



                                } catch (Exception e) {
                                    //print error and exit.
                                    e.printStackTrace();
                                    System.exit(1);
                                }
                            }
                        }

                        Section Summary

                        In this section, I showed two examples of using speech recognition, both of which implemented
                        the JRecognizer interface. The first used Sphinx-4 for Java to demonstrate command and control.
                        The second used JNI and the Microsoft speech recognition engine to give an example of
                        continuous dictation.
                            Before introducing the first example, I gave a brief overview of the Java Speech Grammar
                        Format (JSGF). This is the format of what words the recognizer needs to understand.
                            The classes discussed were
                           • SphinxSR: This is the Java recognizer using command and control.

                           • MicrosoftSR: This is the continuous recognizer using JNI and Microsoft speech recognition
                             engine. (You must train this engine prior to use.)


                        5.3 Chapter Summary

                        In this chapter, I talked about how to get your robot to talk and recognize what you’re saying.
                        I also showed you how to use speech technology written in other languages, and I gave a simple
                        introduction to the Java Native Interface (JNI).
                            The JNI example, TempConvert, does a simple temperature conversion using a C++
                        project and class to perform the calculation. You should be able to follow the step-by-step
                        example to create your own JNI classes.
                            In section 5.1, I introduced the JVoice interface to standardize implementation of the three
                        text-to-speech classes. The first, JavaVoice, uses the Java Speech API (JSAPI) to produce speech
                        from text. The second, FreeTTSVoice, uses the FreeTTS speech synthesis libraries to produce
                        speech from text. The third, MicrosoftVoice, uses JNI to connect the speech synthesizer engine
                        built in to my system after installing the Microsoft Speech API (MSAPI). Also in section 5.1, I
                        showed a sample class that tests the voice quality of all three speech synthesis engines.
                            In section 5.2, I introduced the JRecognizer interface, used for standardizing implementa-
                        tions of the following two speech recognition classes. The first recognizer, SphinxSR, uses a
                        grammar file, a configuration file, and the synthesizer from the Sphinx-4 project. The second
                        recognizer uses JNI to connect to the Microsoft speech recognition engine. Also in section 5.2,
                        I wrote a sample class that echoes what’s heard in continuous dictation.
                            Personally, I like MicrosoftVoice for sound quality and SphinxSR for recognition. I’ll use
                        these in Chapter 9.
                            Now that our PC can speak and listen, it’s time to get it to see, which is the topic of the next
                        chapter.
   177   178   179   180   181   182   183   184   185   186   187