Solved

Java speech - Help needed

Posted on 2004-09-02
16
415 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

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

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!

Question has a verified solution.

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

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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 learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This video teaches viewers about errors in exception handling.
Suggested Courses

734 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