-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVoice.java
49 lines (22 loc) · 973 Bytes
/
Voice.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import com.sun.speech.freetts.VoiceManager;
//import com.sun.speech.freetts.Voice;
import com.sun.speech.freetts.Gender;
public class Voice {
private String name; // name of voice to use
private com.sun.speech.freetts.Voice voice; // empty instance of voice class inside sun.speech
public Voice(String name) {
// set default voice for kevin
System.setProperty("freetts.voices", "com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory");
this.name = name;
this.voice = VoiceManager.getInstance().getVoice(this.name); // gets the voice to the "name" variable
this.voice.allocate();
}
public void say(String something) {
this.voice.speak(something);
}
public void sayMultipleLines(String[] multipleLines){
for(int i = 0; i < multipleLines.length; i++){
this.say(multipleLines[i]);
}
}
}