1 package de.dfki.lt.freetts.en.us;
4 import java.util.Locale;
6 import com.sun.speech.freetts.Age;
7 import com.sun.speech.freetts.Gender;
8 import com.sun.speech.freetts.ValidationException;
9 import com.sun.speech.freetts.Voice;
10 import com.sun.speech.freetts.VoiceDirectory;
11 import com.sun.speech.freetts.en.us.CMULexicon;
12 import com.sun.speech.freetts.util.Utilities;
15 * Provides access to MBROLA voices.
17 public class MbrolaVoiceDirectory extends VoiceDirectory {
19 public Voice[] getVoices() {
21 String base = Utilities.getProperty("mbrola.base", null);
23 if (base == null || base.trim().length() == 0) {
25 "System property \"mbrola.base\" is undefined. "
26 + "Will not use MBROLA voices.");
30 CMULexicon lexicon = new CMULexicon("cmulex");
32 Voice mbrola1 = new MbrolaVoice
33 ("us1", "us1", 150f, 180F, 22F,
34 "mbrola_us1", Gender.FEMALE, Age.YOUNGER_ADULT,
36 Locale.US, "general", "mbrola", lexicon);
38 Voice mbrola2 = new MbrolaVoice
39 ("us2", "us2", 150f, 115F, 12F,
40 "mbrola_us2", Gender.MALE, Age.YOUNGER_ADULT,
42 Locale.US, "general", "mbrola", lexicon);
44 Voice mbrola3 = new MbrolaVoice
45 ("us3", "us3", 150f, 125F, 12F,
46 "mbrola_us3", Gender.MALE, Age.YOUNGER_ADULT,
48 Locale.US, "general", "mbrola", lexicon);
50 Voice[] voices = {mbrola1, mbrola2, mbrola3};
52 List validVoices = new java.util.ArrayList();
55 for (int i = 0; i < voices.length; i++) {
56 MbrolaVoiceValidator validator =
57 new MbrolaVoiceValidator((MbrolaVoice) voices[i]);
60 validVoices.add(voices[i]);
62 } catch (ValidationException ve) {
63 // does nothing if the voice is not found
69 + "Could not validate any MBROLA voices at\n\n"
71 if (base.indexOf('~') != -1) {
73 "DO NOT USE ~ as part of the path name\n"
74 + "to specify the mbrola.base property.");
77 "Make sure you FULLY specify the path to\n"
78 + "the MBROLA directory using the mbrola.base\n"
79 + "system property.\n");
82 return ((Voice[])validVoices.toArray(new Voice[count]));
88 * Prints out the MBROLA voices.
90 public static void main(String[] args) {
91 System.out.println((new MbrolaVoiceDirectory()).toString());