• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Help needed regarding jsapi

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello friends
I am new to jsapi
When i am trying to run the hello world program as given below, it throws a null-pointer exception at the line containing synth.allocate();



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(null);
//new SynthesizerModeDesc(Locale.ENGLISH));


// 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) {
System.out.println("Exception occured :"+e+"\n");
e.printStackTrace();
}
}
}


I am not able to resolve it.
Please help me out.......
It seems that there is some problem with classpath but i am not able to correct it.
Please help.
Thanks in advance................
 
Sheriff
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please Use Code Tags. It will make your code so much easier to read.

Now either synth is null, or there is something wrong inside synth.allocate(). My guess is the former; Central.createSynthesizer(null) probably returns null. That's what the API says:

My guess is that this will always happen if you provide a null EngineModeDesc. Why don't you create one and use it? You already have the code for it, you just commented it out. Why?
 
krish arya
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for your reply
but that is not the case.


I commented that line because that to had no effect on the exception that is being thrown.

Any way i found out what the problem was.
The problem was with the classpath after setting up correctly,the program is executing correctly
but no sound is being produced.

When i tried other demo codes, it worked correctly.
Please help
 
krish arya
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for your reply
but that is not the case.


I commented that line because that to had no effect on the exception that is being thrown.

Any way i found out what the problem was.
The problem was with the classpath after setting up correctly,the program is executing correctly
but no sound is being produced.

When i tried other demo codes, it worked correctly.
Please help
 
But how did the elephant get like that? What did you do? I think all we can do now is read this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic