Solved

Java speech - Help needed

Posted on 2004-09-02
16
411 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
ID: 11964643
Where do you get the npe?
0
 
LVL 35

Expert Comment

by:girionis
ID: 11964656
0
 
LVL 92

Expert Comment

by:objects
ID: 11968953
what speech provider are you using?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:rnavanee
ID: 11970727

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
ID: 11971437
> 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
ID: 11972146
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
ID: 11972172
npe = NullPointerException
0
 

Author Comment

by:rnavanee
ID: 11972265
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
ID: 11972341
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
ID: 11972494
Still I am getting the same error. 'synth' object is null in this case too.
0
 
LVL 35

Expert Comment

by:girionis
ID: 11972614
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
ID: 11977411
> 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
ID: 11993900
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
ID: 11994042
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
runtime exception 2 50
java imports not found 4 47
How to configure empty element in XML Document parser? 15 44
learn programming 8 66
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

735 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