Results 21 to 30 of 30
Thread: java speech Synthesizer
- 07-08-2010, 10:31 AM #21
Member
- Join Date
- Jul 2010
- Posts
- 16
- Rep Power
- 0
- 07-08-2010, 04:27 PM #22
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
You're not bothering me at all; the only thing that bothers me (not really ;-) is that the FreeTTS API works fine but the JSAPI interface on top of it doesn't work at all; the cheap way out is easy: don't use the JSAPI. I think that project is stone dead which isn't an incentive to explore any further ...
kind regards,
Jos
- 07-09-2010, 10:59 AM #23
Member
- Join Date
- Jul 2010
- Posts
- 16
- Rep Power
- 0
import javax.speech.*;
import javax.speech.synthesis.*;
import java.util.*;
public class TellTime {
public static void main(String[] args) {
try {
Calendar calendar = new GregorianCalendar();
String sayTime = "Its " +
calendar.get(Calendar.HOUR) + " " +
calendar.get(Calendar.MINUTE) + " " +
(calendar.get(Calendar.AM_PM)== 0 ? "AM" : "PM");
Synthesizer synth = Central.createSynthesizer(null);
synth.allocate();
synth.resume();
synth.speakPlainText(sayTime,null);
synth.waitEngineState(Synthesizer.QUEUE_EMPTY);
synth.deallocate();
} catch (Exception e) {
e.printStackTrace();
}
}
}
I used this simple code. I put all freetts-1.2 jar files to my classpath and put speech.properties file to java home. But i got this exception.
System property "mbrola.base" is undefined. Will not use MBROLA voices.
Jul 9, 2010 3:42:29 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 com.sun.speech.freetts.jsapi.FreeTTSSynthesizer.se tCurrentVoice(FreeTTSSynthesizer.java:122)
at com.sun.speech.freetts.jsapi.FreeTTSSynthesizer.ha ndleAllocate(FreeTTSSynthesizer.java:85)
at com.sun.speech.engine.BaseEngine.allocate(BaseEngi ne.java:219)
at TellTime.main(TellTime.java:18)
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)
... 4 more
May i know the reason for this.
Regards,
Chaminga.
- 07-09-2010, 11:29 AM #24
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
- 07-09-2010, 11:33 AM #25
Member
- Join Date
- Jul 2010
- Posts
- 16
- Rep Power
- 0
yes sir.
I tried that one. But it also give same error.
System property "mbrola.base" is undefined. Will not use MBROLA voices.
Jul 9, 2010 4:19:22 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-09-2010, 11:45 AM #26
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
There must be something wrong in your .jar file visibility then because the example works for me: I use Java 1.6 and I have the following nine files in my JRE\lib\ext directory (they are always visible there):
My example code runs with that configuration. Try again.Java Code:03/09/2009 01:39 PM 894,905 cmudict04.jar 03/09/2009 01:40 PM 599,429 cmulex.jar 03/09/2009 01:39 PM 1,231 cmutimelex.jar 03/09/2009 01:39 PM 1,723,774 cmu_time_awb.jar 03/09/2009 01:39 PM 4,899,359 cmu_us_kal.jar 03/09/2009 01:40 PM 866,598 en_us.jar 03/09/2009 01:39 PM 208,668 freetts.jar 10/01/2003 11:51 AM 51,811 jsapi.jar 03/09/2009 01:39 PM 11,926 mbrola.jar
kind regards,
JosLast edited by JosAH; 07-10-2010 at 09:04 PM.
- 07-18-2010, 04:49 AM #27
Member
- Join Date
- Jul 2010
- Posts
- 1
- Rep Power
- 0
Thanks Jos ur posts really helped me out thanks alot:)
- 07-18-2010, 07:55 AM #28
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
You're welcome and if you manage to figure out how those 'mbrola' voices work feel free to post here because all my attempts sofar have failed; I think it has to do with over the edge classpath fiddling in the jar files (I haven't looked into them yet); they brag about it in their documentation but I suspect the fiddling has turned against them/us.
kind regards,
Jos
- 03-02-2011, 11:46 AM #29
Member
- Join Date
- Mar 2011
- Posts
- 1
- Rep Power
- 0
Java Speech
M getting the same Error @ synth.allocate();
error:-
java.lang.NullPointerException
can any one help me out
- 01-04-2012, 06:32 PM #30
Member
- Join Date
- Jan 2012
- Posts
- 1
- Rep Power
- 0
Re: java speech Synthesizer
import javax.speech.*;
import javax.speech.synthesis.*;
import java.util.Locale;
import java.util.Scanner;
public class speechtotextdemo {
public static void main(String args[]) {
try {
Scanner s = new Scanner(System.in);
// Create a synthesizer for English
SynthesizerModeDesc desc = new SynthesizerModeDesc(null,"general", Locale.US,null,null);
Synthesizer synthesizer = Central.createSynthesizer(desc);
// Get it ready to speak
synthesizer.allocate();
synthesizer.resume();
// Speak the "any" string
System.out.println("enter the string to be pronounced");
String str = s.nextLine();
synthesizer.speakPlainText(str, null);
// Wait till speaking is done
synthesizer.waitEngineState(Synthesizer.QUEUE_EMPT Y);
// Clean up
synthesizer.deallocate();
} catch (Exception e) {
e.printStackTrace();
}
}
}
perfectly working code. Now plz anyone who could plz tell me how code i generate different kinda voices.???
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