Results 1 to 20 of 30
Thread: java speech Synthesizer
- 07-07-2010, 05:44 AM #1
Member
- Join Date
- Jul 2010
- Posts
- 16
- Rep Power
- 0
java speech Synthesizer
i'm new to java speech api. and i want to build simple java speech application. This is the code
when i use this code it gives java.lang.NullPointerException.Java Code:import javax.speech.*; import javax.speech.synthesis.*; import java.util.Locale; public class HelloWorld { 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 synth.allocate(); synth.resume(); // Speak the "Hello world" string synth.speakPlainText("Hello, world!", null); // Wait till speaking is done synth.waitEngineState(Synthesizer.QUEUE_EMPTY); // Clean up synth.deallocate(); } catch (Exception e) { e.printStackTrace(); } } }
I would be great full if anybody can explain the reason for the exception.
Reguards
Chaminga.Last edited by Eranga; 07-07-2010 at 05:58 AM. Reason: code tags added
- 07-07-2010, 05:57 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Can you post the complete error message here to see?
- 07-07-2010, 06:00 AM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
And also please use the code tags next time when you are posting here in the forum. Unformated codes are really hard to read. If you don't know how to do it, check my forum signature.
- 07-07-2010, 06:08 AM #4
Member
- Join Date
- Jul 2010
- Posts
- 16
- Rep Power
- 0
I would be really thank full to your reply.
Complete error message is
java.lang.NullPointerException at HelloWorld.main(HelloWorld.java:17)
- 07-07-2010, 06:09 AM #5
Member
- Join Date
- Jul 2010
- Posts
- 16
- Rep Power
- 0
Error occurred because of synth.allocate();
- 07-07-2010, 06:10 AM #6
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
What you've on line 17? I cannot see any line numbers, so it's better to sent it.
Actually what you've post in the above post is not the complete error, or the stack trace you comes with. Post the complete message.
- 07-07-2010, 06:27 AM #7
Member
- Join Date
- Jul 2010
- Posts
- 16
- Rep Power
- 0
line 17th is synth.allocate();
may i know the reason for the Nullpoint Exception.
thank you
- 07-07-2010, 06:34 AM #8
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Your synth object could be null. Did you check that?
- 07-07-2010, 06:43 AM #9
Member
- Join Date
- Jul 2010
- Posts
- 16
- Rep Power
- 0
hmmmm i checked :(
really really thankful to ur help.
- 07-07-2010, 06:44 AM #10
Member
- Join Date
- Jul 2010
- Posts
- 16
- Rep Power
- 0
hmmmm i checked :(
really really thankful to ur help.
- 07-07-2010, 08:14 AM #11
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
Have you actually installed one of the available speech systems? Note that this Java extension (javax.speech) just offers the 'Java way' of a speech synthesis system, you need an actual system to do the job; compare this with the jdbc framework: you still need a database engine to do the job; the jdbc classes just give you the API.
kind regards,
Jos
- 07-07-2010, 11:31 AM #12
Member
- Join Date
- Jul 2010
- Posts
- 16
- Rep Power
- 0
Thank u jos.
Do i need to install any other application to avoid this problem.
regards,
Malmi.
- 07-07-2010, 12:01 PM #13
Member
- Join Date
- Jul 2010
- Posts
- 16
- Rep Power
- 0
What is FreeTTS 1.2
is that support for java speech api.
regards,
Chaminga.
- 07-07-2010, 03:47 PM #14
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
Yes, use that one; I did the same today and incorporated it in my own private language; it comes with two APIs: its own and the JSAPI stuff; it's a bit of a hassle to install everything properly but it works with a few different voices and they keep on whining about a 'mbrola' database not being installed; the documentation tells you more about that mbrola initiative (it doesn't run properly with MS Windows).
kind regards,
Jos
- 07-08-2010, 05:19 AM #15
Member
- Join Date
- Jul 2010
- Posts
- 16
- Rep Power
- 0
Thank u Jos.
Regards,
Chaminga.
- 07-08-2010, 08:00 AM #16
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
- 07-08-2010, 08:27 AM #17
Member
- Join Date
- Jul 2010
- Posts
- 16
- Rep Power
- 0
Hi Jos,
I tried using FreeTTS but still i cannot find the reason for the error.
I really really want to build speaking application but i'm still on the start. :(
regards,
Chaminga.
- 07-08-2010, 08:36 AM #18
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
What errors? This is my little test program and it works (you have to make most of the jars visible in the ./lib folder). Note the nasty mbrola blahblahblah message on stdout. Also note that I'm using freeTTS's own API ...
kind regards,Java Code:import com.sun.speech.freetts.Voice; import com.sun.speech.freetts.VoiceManager; public class T { public static void main(String[] args) { String voiceName = "kevin16"; // the only usable general purpose voice VoiceManager voiceManager = VoiceManager.getInstance(); Voice voice = voiceManager.getVoice(voiceName); // some effects: // helloVoice.setPitch(20.0f); // helloVoice.setDurationStretch(0.3f); // helloVoice.setRate(100.0f); // helloVoice.setVolume(1.0f); voice.allocate(); voice.speak("Oh man this is a crappy voice"); voice.deallocate(); } }
Jos
- 07-08-2010, 10:18 AM #19
Member
- Join Date
- Jul 2010
- Posts
- 16
- Rep Power
- 0
I used this code
then i got this error. May i know the reason for that sir.
System property "mbrola.base" is undefined. Will not use MBROLA voices.
Jul 8, 2010 2:30:13 PM com.sun.speech.freetts.Voice allocate
SEVERE: Can't load voice java.util.zip.ZipException: ZipFile closed
Exception in thread "main" java.lang.Error: java.util.zip.ZipException: ZipFile closed
at com.sun.speech.freetts.Voice.allocate(Voice.java:3 51)
at T.main(T.java:21)
Caused by: java.util.zip.ZipException: ZipFile closed
at java.util.zip.ZipFile.ensureOpenOrZipException(Zip File.java:413)
at java.util.zip.ZipFile.access$1100(ZipFile.java:29)
at java.util.zip.ZipFile$ZipFileInputStream.read(ZipF ile.java:445)
at java.util.zip.ZipFile$1.fill(ZipFile.java:230)
at java.util.zip.InflaterInputStream.read(InflaterInp utStream.java:141)
at java.io.FilterInputStream.read(FilterInputStream.j ava:116)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.j ava:264)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.ja va:306)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:1 58)
at java.io.InputStreamReader.read(InputStreamReader.j ava:167)
at java.io.BufferedReader.fill(BufferedReader.java:13 6)
at java.io.BufferedReader.readLine(BufferedReader.jav a:299)
at java.io.BufferedReader.readLine(BufferedReader.jav a:362)
at com.sun.speech.freetts.en.us.PronounceableFSM.load Text(PronounceableFSM.java:91)
at com.sun.speech.freetts.en.us.PronounceableFSM.<ini t>(PronounceableFSM.java:60)
at com.sun.speech.freetts.en.us.PrefixFSM.<init>(Pref ixFSM.java:26)
at com.sun.speech.freetts.en.us.CMUVoice.setupUtteran ceProcessors(CMUVoice.java:116)
at com.sun.speech.freetts.en.us.CMUVoice.loader(CMUVo ice.java:77)
at com.sun.speech.freetts.Voice.allocate(Voice.java:3 48)
... 1 more
regards,
Chaminga.
- 07-08-2010, 10:26 AM #20
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
Not all the .jar files are visible from your class (also reread my previous reply). For the time being stick them all in the lib/ext directory of your JRE so they always can be found. You need all the cmu*.jar files, the en_us.jar file, freetts, jsapi, mbrola and the voices jar files.
kind regards,
Jos
Similar Threads
-
Speech in Web Application
By vinoopraj in forum Advanced JavaReplies: 0Last Post: 06-23-2010, 11:27 AM -
Speech Recognition In Java
By hackernewbie in forum Advanced JavaReplies: 6Last Post: 01-18-2010, 11:06 PM -
Java Speech Processing
By redvirus in forum CLDC and MIDPReplies: 2Last Post: 10-03-2009, 12:16 AM -
Help with Java Speech API (Synthesizer)
By mohitkhanna3v_infinate in forum Advanced JavaReplies: 1Last Post: 07-23-2009, 06:21 PM -
Java Speech Recognizer
By Lynx09 in forum Advanced JavaReplies: 0Last Post: 03-30-2009, 08:10 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks