1 package org.wcb.plugins.speech;
2
3 import javax.speech.synthesis.Synthesizer;
4 import javax.speech.EngineException;
5 import javax.speech.AudioException;
6
7 /***
8 *This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21 *
22 * Project: Home Automation Interface
23 * Filename: $Id: SynthesizerLoader.java,v 1.3 2004/02/27 01:29:53 wbogaardt Exp $
24 * Abstract: Web bean for x10 jsp.
25 *
26 * $Log: SynthesizerLoader.java,v $
27 * Revision 1.3 2004/02/27 01:29:53 wbogaardt
28 * modified classes so they conform to Checkstyle format in readability
29 *
30 * Revision 1.2 2003/12/18 17:35:53 wbogaardt
31 * fixed speech engine issue so that the application does not lock up but will notify user of the need to
32 * install speech.properties file in their home directory.
33 *
34 * Revision 1.1 2003/12/11 21:58:42 wbogaardt
35 * added speach synthesizer using java speech api
36 *
37 *
38 * A Thread that loads the Synthesizer.
39 */
40 public class SynthesizerLoader extends Thread {
41 private Synthesizer synthesizer;
42
43 /***
44 * Constructs a SynthesizerLoaded which loads the given Synthesizer.
45 *
46 * @param synth the Synthesizer to load
47 * the PlayerModel
48 */
49 public SynthesizerLoader(Synthesizer synth)
50 {
51 this.synthesizer = synth;
52 }
53
54 /***
55 * Implements the <code>run()</code> method of the Thread class.
56 */
57 public void run()
58 {
59 try
60 {
61 if (synthesizer != null)
62 {
63 System.out.println("allocating...");
64 synthesizer.allocate();
65 System.out.println("...allocated");
66 synthesizer.resume();
67 System.out.println("...resume");
68 }
69 else
70 {
71 System.err.println("Check that speech.properties is installed at "
72 + System.getProperty("user.home"));
73 }
74 }
75 catch (EngineException e)
76 {
77 System.err.println("Engine allocation error " + e.getMessage());
78 }
79 catch (AudioException ae)
80 {
81 System.err.println("No audio found " + ae.getMessage());
82 }
83 }
84 }