Switch AltosUI to libaltos for device access
[fw/altos] / ao-tools / altosui / AltosVoice.java
1 /*
2  * Copyright © 2010 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 2 of the License.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
16  */
17
18 package altosui;
19
20 /*import com.sun.speech.freetts.Voice;
21 import com.sun.speech.freetts.VoiceManager;
22 import com.sun.speech.freetts.audio.JavaClipAudioPlayer; */
23 import java.util.concurrent.LinkedBlockingQueue;
24
25 public class AltosVoice implements Runnable {
26 /*
27         VoiceManager                    voice_manager;
28         Voice                           voice;
29 */
30         LinkedBlockingQueue<String>     phrases;
31         Thread                          thread;
32
33         final static String voice_name = "kevin16";
34
35         public void run() {
36                 try {
37                         for (;;) {
38                                 String s = phrases.take();
39 /*                              voice.speak(s); */
40                         }
41                 } catch (InterruptedException e) {
42                 }
43         }
44         public void speak(String s) {
45                 try {
46 /*                      if (voice != null) */
47                                 phrases.put(s);
48                 } catch (InterruptedException e) {
49                 }
50         }
51
52         public AltosVoice () {
53 /*              voice_manager = VoiceManager.getInstance();
54                 voice = voice_manager.getVoice(voice_name);
55                 if (voice != null)  */ {
56 /*                      voice.allocate(); */
57                         phrases = new LinkedBlockingQueue<String> ();
58                         thread = new Thread(this);
59                         thread.start();
60                         speak("Rocket Flight Monitor Ready");
61                 } /* else {
62                         System.out.printf("Voice manager failed to open %s\n", voice_name);
63                         Voice[] voices = voice_manager.getVoices();
64                         System.out.printf("Available voices:\n");
65                         for (int i = 0; i < voices.length; i++) {
66                                 System.out.println("    " + voices[i].getName()
67                                                    + " (" + voices[i].getDomain() + " domain)");
68                         }
69                         } */
70         }
71 }