Solved

Java speech - Help needed

Posted on 2004-09-02
16
418 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 92

Expert Comment

by:objects
ID: 11968953
what speech provider are you using?
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
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 …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

705 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