Solved

Java speech - Help needed

Posted on 2004-09-02
16
380 Views
Last Modified: 2012-05-05
Hi,

I am involved in a project that will read out the text in a page (like
text-to-speect tool). I have planned to use Java for this purpose.

I saw a sample code in a web site. It makes use of the classes from
the package 'javax.speech'. This package is not available with the
standard JDK. So i downloaded the pacakge from IBM site. The following
piece of code compiled with no issues. When I ran the code I am
getting 'NullPointerException'. Any idea why this happens?

Also give me some tips on how to proceed this project in Java using JSML?

Source code:

>>>>
import javax.speech.*;
import javax.speech.synthesis.*;
import java.util.Locale;

public class jsapi_hw {
public static void main(String args[]) {
try {
// Create a synthesizer for English
Synthesizer synth = Central.createSynthesizer(
new SynthesizerModeDesc(Locale.ENGLISH));
// Get it ready to speak

System.out.println("1"+synth);
synth.allocate();
System.out.println("2");
synth.resume();
System.out.println("3");
// Speak the "Hello world" string
synth.speakPlainText("Hello, world!", null);
System.out.println("4");
// Wait till speaking is done
synth.waitEngineState(Synthesizer.QUEUE_EMPTY);
System.out.println("5");
// Clean up
synth.deallocate();
} catch (Exception e) {
e.printStackTrace();
}
}
}

>>>>

When i debugged i found the 'synth' object is null.

Thanks & Regards,
Navanee
0
Comment
Question by:rnavanee
  • 6
  • 5
  • 3
16 Comments
 
LVL 35

Expert Comment

by:girionis
Comment Utility
Where do you get the npe?
0
 
LVL 35

Expert Comment

by:girionis
Comment Utility
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
what speech provider are you using?
0
 

Author Comment

by:rnavanee
Comment Utility

I have installled the IBM's javax.speech pacakge (ibmjs.jar). Do i need to install anything else? Am i required to install IBM's Via Voice? If so, can you please give me a link for downloading a free copy of Via Voice?


Thanks in Advance,
Navanee
0
 
LVL 35

Expert Comment

by:girionis
Comment Utility
> I have installled the IBM's javax.speech pacakge (ibmjs.jar). Do i need to install anything else?

You shouldn't need but better take a look at the documentation. Where exactly is the npe?
0
 

Author Comment

by:rnavanee
Comment Utility
Sorry that i do not understand what you mean by 'npe'? Can you please expand the term 'npe'?
0
 
LVL 35

Expert Comment

by:girionis
Comment Utility
npe = NullPointerException
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:rnavanee
Comment Utility
The 'synth' object is null.

So when this line is executed I am getting the NPE:

>>>>
synth.allocate();
>>>>

Please help me!!

-- Navanee
0
 
LVL 35

Expert Comment

by:girionis
Comment Utility
What happens if you change this line:

> Synthesizer synth = Central.createSynthesizer(
new SynthesizerModeDesc(Locale.ENGLISH));

to this:

Synthesizer synth = Central.createSynthesizer(null);
0
 

Author Comment

by:rnavanee
Comment Utility
Still I am getting the same error. 'synth' object is null in this case too.
0
 
LVL 35

Expert Comment

by:girionis
Comment Utility
The Central class returns null for some reason. Better take a look at the docs and see what they say.
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
> I have installled the IBM's javax.speech pacakge (ibmjs.jar). Do i need to install anything else?

yes you need a speech provider

> Am i required to install IBM's Via Voice?

That is one option

> If so, can you please give me a link for downloading a free copy of Via Voice?

I don't think one exists any more
0
 

Author Comment

by:rnavanee
Comment Utility
Is there any other free speech provider available? If so, please give me related links.

Thanks in advance,
Navanee
0
 
LVL 92

Accepted Solution

by:
objects earned 125 total points
Comment Utility
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to implement Singleton Design Pattern in Java.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now