This discussion is archived
7 Replies Latest reply: Apr 28, 2009 11:52 PM by 843802 RSS

JSAPI : Problems with the speech recognition HelloWorld example

843802 Newbie
Currently Being Moderated
I just started off with JSAPI. And I immediately ran into problems. These are the configurations and the stuff I did:

My system:
OS: WinXP
JDK: JDK 6 Update 10
IDE: Netbeans 6.0

I downloaded the FreeTTS.zip from the FreeTTS site [http://freetts.sourceforge.net/docs/index.php] . I expanded it and in the lib folder I ran the jsapi.exe and as a result jsapi.jar war generated.

I included this jar in my project lib as jar.

Then I copy pasted HelloWorld speech recognition example code given in the site : [http://java.sun.com/products/java-media/speech/forDevelopers/jsapi-guide/Recognition.html#11644]

First it gave a compile time error that
rec.deallocate();
throws an exception which needs to be handled. Accordingly I surrounded it with a try catch block and caught the exceptions in the manner given below:
   try{
        ...
        ...
         rec.deallocate();
                    System.exit(0);
                } catch (EngineException ex) {
                    Logger.getLogger(HelloWorld.class.getName()).log(Level.SEVERE, null, ex);
                } catch (EngineStateError ex) {
                    Logger.getLogger(HelloWorld.class.getName()).log(Level.SEVERE, null, ex);
                }
 
Now the code was compiling without problems.

When I executed the code a runtime exception (NullPointerException) was thrown at the line
      rec.allocate();  
in the psvm(String args[])


Can anybody please explain to me where I am going wrong? Or is there something more that needs to be added in the code?

Anxiously waiting to hear from your end.

Thanks and regards,
  • 1. Re: JSAPI : Problems with the speech recognition HelloWorld example
    843802 Newbie
    Currently Being Moderated
    Hi All,

    I am using following code
    import javax.speech.*;
    import javax.speech.synthesis.*;
    import java.util.Locale;
    
    public class HelloWorld {
         public static void main(String args[]) {
              try {
                   // Create a synthesizer for English
    
    
                   Synthesizer synth = Central.createSynthesizer(
                        new SynthesizerModeDesc(Locale.ENGLISH));
                               synth.waitEngineState(Synthesizer.ALLOCATED);
                   //Synthesizer synth = Central.createSynthesizer (null);
    
    
                   // Get it ready to speak
                   synth.allocate();
                   synth.resume();
    
                   // Speak the "Hello world" string
                   synth.speakPlainText("Hello, world!", null);
    
                   // Wait till speaking is done
                   synth.waitEngineState(Synthesizer.QUEUE_EMPTY);
    
                   // Clean up
                   synth.deallocate();
              } catch (Exception e) {
                   e.printStackTrace();
              }
         }
    }
    and i am also getting following error
    java.lang.NullPointerException
            at HelloWorld.main(HelloWorld.java:18)
    My class path is set to
    jsapi.jar (extracted from freetts 1.2.1)
    freetts.jar


    Please i didn't find any solution from past replies so please do help me someone to solve this...

    Thanking You....
  • 2. Re: JSAPI : Problems with the speech recognition HelloWorld example
    843802 Newbie
    Currently Being Moderated
    Hi guys, Since you are all using FTTS, you have to set the class path correctly for jsapi to run your program.
    So, it seems you are beginner of JSAPI. If so, then i advice you to use CloudsGardans JSAPI. It doesnt want any manual class path setting. Just install it, and all your examples program will work.
    [Dont worry because, its a trial version. I know the way to extend its trial period, so that it wont end]
  • 3. Re: JSAPI : Problems with the speech recognition HelloWorld example
    843802 Newbie
    Currently Being Moderated
    can you please tell me the way to extend cloudgarden trial to full version.
  • 4. Re: JSAPI : Problems with the speech recognition HelloWorld example
    843802 Newbie
    Currently Being Moderated
    hai all,
    adding jsapi.jar is not sufficient!
    u have to add all the jar files from the lib directory under freetts,
    i worked out successfully, u can find the sample code and clear explanation in this thread
    http://forums.sun.com/thread.jspa?threadID=5366942&tstart=0

    Edited by: vijay.katta on Feb 19, 2009 2:23 PM
  • 5. Re: JSAPI : Problems with the speech recognition HelloWorld example
    843802 Newbie
    Currently Being Moderated
    We've had the same problem. Has anyone responded with a solution that works? Let me know, I'd be very grateful. thanks! [Resume Templates|http://www.resumetemplates-usa.com/resume-templates/]
  • 6. Re: JSAPI : Problems with the speech recognition HelloWorld example
    791266 Explorer
    Currently Being Moderated
    FleurB wrote:
    We've had the same problem. Has anyone responded with a solution that works? Let me know, I'd be very grateful. thanks!
    Don't link spam. I'm blocking your post.
  • 7. Re: JSAPI : Problems with the speech recognition HelloWorld example
    843802 Newbie
    Currently Being Moderated
    FreeTTS is a speech synthesizer and does not include a speech recognizer.