• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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: 22783
131
Eclipse IDE Spring VI Editor 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
 
To get a wish, you need a genie. To get a genie, you need a lamp. To get a lamp, you need a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic