Solved

Java speech - Help needed

Posted on 2004-09-02
16
404 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

 

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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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
print map entry 34 71
SHA2 certs for IIS AND Java? 2 113
iterator/ListIterator approach 17 39
Desingning Refactoring existing code 2 26
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

791 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