2 * Copyright 2003 Sun Microsystems, Inc.
4 * See the file "license.terms" for information on usage and
5 * redistribution of this file, and for a DISCLAIMER OF ALL
9 import com.sun.speech.freetts.jsapi.FreeTTSEngineCentral;
11 import java.util.Locale;
13 import javax.speech.EngineList;
14 import javax.speech.EngineCreate;
15 import javax.speech.synthesis.Synthesizer;
16 import javax.speech.synthesis.SynthesizerModeDesc;
19 * A talking clock powered by FreeTTS.
21 public class JSAPIClock extends Clock {
23 protected Synthesizer synthesizer;
27 * Creates the synthesizer, called by the constructor.
29 public void createSynthesizer() {
32 SynthesizerModeDesc desc =
33 new SynthesizerModeDesc(null,
39 FreeTTSEngineCentral central = new FreeTTSEngineCentral();
40 EngineList list = central.createEngineList(desc);
42 if (list.size() > 0) {
43 EngineCreate creator = (EngineCreate) list.get(0);
44 synthesizer = (Synthesizer) creator.createEngine();
46 if (synthesizer == null) {
47 System.err.println("Cannot create synthesizer");
50 synthesizer.allocate();
53 } catch (Exception e) {
60 * Speaks the given time in full text.
62 * @param time time in full text
64 protected void speak(String time) {
65 synthesizer.speakPlainText(time, null);
70 * main() method to run the JSAPIClock.
72 public static void main(String args[]) {
73 Clock frame = new JSAPIClock();
75 frame.setVisible(true);
76 frame.createSynthesizer();