File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Java Speech HELP!!!!!" Watch "Java Speech HELP!!!!!" New topic

Java Speech HELP!!!!!

Harvi Khaira

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


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);



} catch (Exception e) {
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
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

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

I agree. Here's the link:
subject: Java Speech HELP!!!!!
It's not a secret anymore!