aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes Java Speech HELP!!!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Java Speech HELP!!!!!" Watch "Java Speech HELP!!!!!" New topic
Author

Java Speech HELP!!!!!

Harvi Khaira
Greenhorn

Joined: Feb 26, 2009
Posts: 17
I am an undergraduate student and i need some assistance in using Java Speech in NetBeans IDE (5.5)

I've got my classpaths etc all set and using one demo (very complexed and overcomplicated for my use) and that seems to work ok i think, but the one that ive copied off the internet (see below) as a demo doesnt actually work properly. its meant to output the current time but it only says the last minute or so, e.g. if the time was 11:01, it would only output "... one".

Can anyone help me out as i need the Speech output to work for my dissertation and i cant get it to work - been trying for 2 - 3 weeks

Many thanks

Harv

==================================================================================================================
package jsapi_demo;

import javax.speech.*;
import javax.speech.synthesis.*;
import java.util.*;

public class WhatTimeIsIt {

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();
}
}
}
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42908
    
  69
Why don't you start with the code that you have and is working, instead of starting with the code that doesn't work? You could remove all the unnecessary stuff piece by piece, checking that it still works at each step, until you've cut it down to what you need. That way you'd always have working code.
Harvi Khaira
Greenhorn

Joined: Feb 26, 2009
Posts: 17
I would do but its all linked to other classes and then it links back to a website which it works off so its pretty difficult (and pointless). Ive even shown it to my supervisor and he couldnt work out that if it was stripped, what would be classed as worthwhile to keep and whats just extra junk

so ive already tried that, before scouring the internet for anything else that may be able to help

Harv
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Speech HELP!!!!!