2 * Copyright © 2010 Keith Packard <keithp@keithp.com>
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.
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.
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.
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;
25 public class AltosVoice implements Runnable {
26 VoiceManager voice_manager;
28 LinkedBlockingQueue<String> phrases;
31 final static String voice_name = "kevin16";
36 String s = phrases.take();
39 } catch (InterruptedException e) {
43 public void speak_always(String s) {
47 } catch (InterruptedException e) {
51 public void speak(String s) {
52 if (AltosPreferences.voice())
56 public void speak(String format, Object... parameters) {
57 speak(String.format(format, parameters));
60 public AltosVoice () {
61 voice_manager = VoiceManager.getInstance();
62 voice = voice_manager.getVoice(voice_name);
65 phrases = new LinkedBlockingQueue<String> ();
66 thread = new Thread(this);
69 System.out.printf("Voice manager failed to open %s\n", voice_name);
70 Voice[] voices = voice_manager.getVoices();
71 System.out.printf("Available voices:\n");
72 for (int i = 0; i < voices.length; i++) {
73 System.out.println(" " + voices[i].getName()
74 + " (" + voices[i].getDomain() + " domain)");