Skip to content

Commit d703e8c

Browse files
committed
some code cleanup
1 parent 8691c5e commit d703e8c

File tree

2 files changed

+323
-331
lines changed

2 files changed

+323
-331
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,103 @@
1-
/*
2-
* File: $HeadURL: https://svn.sourceforge.net/svnroot/jvoicexml/trunk/src/org/jvoicexml/Application.java$
3-
* Version: $LastChangedRevision: 296 $
4-
* Date: $LastChangedDate $
5-
* Author: $LastChangedBy: schnelle $
6-
*
7-
* JSAPI - An independent reference implementation of JSR 113.
8-
*
9-
* Copyright (C) 2007-2012 JVoiceXML group - http://jvoicexml.sourceforge.net
10-
*
11-
* This library is free software; you can redistribute it and/or
12-
* modify it under the terms of the GNU Library General Public
13-
* License as published by the Free Software Foundation; either
14-
* version 2 of the License, or (at your option) any later version.
15-
*
16-
* This library is distributed in the hope that it will be useful,
17-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19-
* Library General Public License for more details.
20-
*
21-
* You should have received a copy of the GNU Library General Public
22-
* License along with this library; if not, write to the Free Software
23-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24-
*
25-
*/
26-
27-
package org.jvoicexml.jsapi2.demo.helloworld;
28-
29-
import java.util.logging.ConsoleHandler;
30-
import java.util.logging.Handler;
31-
import java.util.logging.Level;
32-
import java.util.logging.Logger;
33-
34-
import javax.speech.EngineManager;
35-
import javax.speech.synthesis.SpeakableEvent;
36-
import javax.speech.synthesis.SpeakableListener;
37-
import javax.speech.synthesis.Synthesizer;
38-
import javax.speech.synthesis.SynthesizerEvent;
39-
import javax.speech.synthesis.SynthesizerListener;
40-
import javax.speech.synthesis.SynthesizerMode;
41-
42-
import org.jvoicexml.jsapi2.synthesis.freetts.FreeTTSEngineListFactory;
43-
44-
/**
45-
* A demo to output a synthesized text to the speaker.
46-
* @author Dirk Schnelle-Walka
47-
* @version $Revision: 593 $
48-
*/
49-
public final class HelloWorldDemo implements SpeakableListener, SynthesizerListener {
50-
/**
51-
* Do not create from outside.
52-
*/
53-
private HelloWorldDemo() {
54-
}
55-
56-
/**
57-
* Starts this demo.
58-
* @param args command line arguments.
59-
*/
60-
public static void main(final String[] args) {
61-
// Enable logging at all levels.
62-
Handler handler = new ConsoleHandler();
63-
handler.setLevel(Level.ALL);
64-
Logger.getLogger("").addHandler(handler);
65-
Logger.getLogger("").setLevel(Level.ALL);
66-
67-
try {
68-
EngineManager
69-
.registerEngineListFactory(FreeTTSEngineListFactory.class
70-
.getName());
71-
// Create a synthesizer for the default Locale
72-
Synthesizer synthesizer = (Synthesizer) EngineManager
73-
.createEngine(SynthesizerMode.DEFAULT);
74-
HelloWorldDemo demo = new HelloWorldDemo();
75-
synthesizer.addSynthesizerListener(demo);
76-
// Get it ready to speak
77-
synthesizer.allocate();
78-
synthesizer.resume();
79-
synthesizer.waitEngineState(Synthesizer.RESUMED);
80-
81-
// Speak the "hello world" string
82-
System.out.println("Speaking 'Hello, world!'...");
83-
synthesizer.speak("Hello, world!", demo);
84-
synthesizer.speakMarkup("<?xml version=\"1.0\"?>"
85-
+ "<speak>Goodbye!</speak>", demo);
86-
synthesizer.waitEngineState(Synthesizer.QUEUE_EMPTY);
87-
System.out.println("done.");
88-
// Clean up - includes waiting for the queue to empty
89-
synthesizer.deallocate();
90-
System.exit(0);
91-
} catch (Exception e) {
92-
e.printStackTrace();
93-
}
94-
}
95-
96-
/**
97-
* {@inheritDoc}
98-
*/
99-
@Override
100-
public void speakableUpdate(SpeakableEvent e) {
101-
System.out.println(e);
102-
}
103-
104-
/**
105-
* {@inheritDoc}
106-
*/
107-
@Override
108-
public void synthesizerUpdate(SynthesizerEvent e) {
109-
System.out.println(e);
110-
}
111-
}
1+
/*
2+
* Copyright (C) 2007-2017 JVoiceXML group - http://jvoicexml.sourceforge.net
3+
*
4+
* This library is free software; you can redistribute it and/or
5+
* modify it under the terms of the GNU Library General Public
6+
* License as published by the Free Software Foundation; either
7+
* version 2 of the License, or (at your option) any later version.
8+
*
9+
* This library is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
* Library General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Library General Public
15+
* License along with this library; if not, write to the Free Software
16+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17+
*
18+
*/
19+
20+
package org.jvoicexml.jsapi2.demo.helloworld;
21+
22+
import java.util.logging.ConsoleHandler;
23+
import java.util.logging.Handler;
24+
import java.util.logging.Level;
25+
import java.util.logging.Logger;
26+
27+
import javax.speech.EngineManager;
28+
import javax.speech.synthesis.SpeakableEvent;
29+
import javax.speech.synthesis.SpeakableListener;
30+
import javax.speech.synthesis.Synthesizer;
31+
import javax.speech.synthesis.SynthesizerEvent;
32+
import javax.speech.synthesis.SynthesizerListener;
33+
import javax.speech.synthesis.SynthesizerMode;
34+
35+
import org.jvoicexml.jsapi2.synthesis.freetts.FreeTTSEngineListFactory;
36+
37+
/**
38+
* A demo to output a synthesized text to the speaker.
39+
* @author Dirk Schnelle-Walka
40+
*/
41+
public final class HelloWorldDemo implements SpeakableListener, SynthesizerListener {
42+
/**
43+
* Do not create from outside.
44+
*/
45+
private HelloWorldDemo() {
46+
}
47+
48+
/**
49+
* Starts this demo.
50+
* @param args command line arguments.
51+
*/
52+
public static void main(final String[] args) {
53+
// Enable logging at all levels.
54+
Handler handler = new ConsoleHandler();
55+
handler.setLevel(Level.ALL);
56+
Logger.getLogger("").addHandler(handler);
57+
Logger.getLogger("").setLevel(Level.ALL);
58+
59+
try {
60+
EngineManager
61+
.registerEngineListFactory(FreeTTSEngineListFactory.class
62+
.getName());
63+
// Create a synthesizer for the default Locale
64+
Synthesizer synthesizer = (Synthesizer) EngineManager
65+
.createEngine(SynthesizerMode.DEFAULT);
66+
HelloWorldDemo demo = new HelloWorldDemo();
67+
synthesizer.addSynthesizerListener(demo);
68+
// Get it ready to speak
69+
synthesizer.allocate();
70+
synthesizer.resume();
71+
synthesizer.waitEngineState(Synthesizer.RESUMED);
72+
73+
// Speak the "hello world" string
74+
System.out.println("Speaking 'Hello, world!'...");
75+
synthesizer.speak("Hello, world!", demo);
76+
synthesizer.speakMarkup("<?xml version=\"1.0\"?>"
77+
+ "<speak>Goodbye!</speak>", demo);
78+
synthesizer.waitEngineState(Synthesizer.QUEUE_EMPTY);
79+
System.out.println("done.");
80+
// Clean up - includes waiting for the queue to empty
81+
synthesizer.deallocate();
82+
System.exit(0);
83+
} catch (Exception e) {
84+
e.printStackTrace();
85+
}
86+
}
87+
88+
/**
89+
* {@inheritDoc}
90+
*/
91+
@Override
92+
public void speakableUpdate(SpeakableEvent e) {
93+
System.out.println(e);
94+
}
95+
96+
/**
97+
* {@inheritDoc}
98+
*/
99+
@Override
100+
public void synthesizerUpdate(SynthesizerEvent e) {
101+
System.out.println(e);
102+
}
103+
}

0 commit comments

Comments
 (0)