upstream version 1.2.2
[debian/freetts] / com / sun / speech / freetts / en / us / CMUClusterUnitVoice.java
1 /**
2  * Portions Copyright 2001 Sun Microsystems, Inc.
3  * Portions Copyright 1999-2001 Language Technologies Institute, 
4  * Carnegie Mellon University.
5  * All Rights Reserved.  Use is subject to license terms.
6  * 
7  * See the file "license.terms" for information on usage and
8  * redistribution of this file, and for a DISCLAIMER OF ALL 
9  * WARRANTIES.
10  */
11 package com.sun.speech.freetts.en.us;
12
13 import java.io.IOException;
14 import java.net.URL;
15 import java.util.Locale;
16
17 import com.sun.speech.freetts.Age;
18 import com.sun.speech.freetts.Gender;
19 import com.sun.speech.freetts.UtteranceProcessor;
20 import com.sun.speech.freetts.clunits.ClusterUnitPitchmarkGenerator;
21 import com.sun.speech.freetts.clunits.ClusterUnitSelector;
22 import com.sun.speech.freetts.relp.UnitConcatenator;
23
24 import de.dfki.lt.freetts.ConcatenativeVoice;
25
26 /**
27  * Defines voice that does cluster unit selection.
28  */
29 public class CMUClusterUnitVoice extends CMUVoice implements ConcatenativeVoice {
30
31     protected URL database;
32
33     /**
34      * Creates a simple cluster unit voice
35      *
36      * @param name the name of the voice
37      * @param gender the gender of the voice
38      * @param age the age of the voice
39      * @param description a human-readable string providing a
40      * description that can be displayed for the users.
41      * @param locale the locale of the voice
42      * @param domain the domain of this voice.  For example,
43      * @param organization the organization which created the voice
44      * "general", "time", or
45      * "weather".
46      * @param lexicon the lexicon to load
47      * @param database the url to the database containing unit data
48      * for this voice.
49      */
50     public CMUClusterUnitVoice(String name, Gender gender, Age age,
51             String description, Locale locale, String domain,
52             String organization, CMULexicon lexicon, URL database) {
53         super(name, gender, age, description, locale,
54                 domain, organization, lexicon);
55         setRate(150f);
56         setPitch(100F);
57         setPitchRange(12F);
58         this.database = database;
59     }
60
61     /**
62      * Gets the url to the database that defines the unit data for this
63      * voice.
64      *
65      * @return a url to the database
66      */
67     public URL getDatabase() {
68         return database;
69     }
70
71     /**
72      * Sets up the FeatureSet for this Voice.
73      *
74      * @throws IOException if an I/O error occurs
75      */
76     protected void setupFeatureSet() throws IOException {
77         super.setupFeatureSet();
78         getFeatures().setString(FEATURE_JOIN_TYPE, "simple_join");
79     }
80
81     /**
82      * Returns the unit selector to be used by this voice.
83      * Derived voices typically override this to customize behaviors.
84      * This voice uses  a cluster unit selector as the unit selector.
85      * 
86      * @return the post lexical processor
87      * 
88      * @throws IOException if an IO error occurs while getting
89      *     processor
90      */
91     public UtteranceProcessor getUnitSelector() throws IOException {
92         return new ClusterUnitSelector(getDatabase());
93     }
94
95     /**
96      * Returns the pitch mark generator to be used by this voice.
97      * Derived voices typically override this to customize behaviors.
98      * There is no default unit selector
99      * 
100      * @return the post lexical processor
101      * 
102      * @throws IOException if an IO error occurs while getting
103      *     processor
104      */
105     public UtteranceProcessor getPitchmarkGenerator() throws IOException {
106         return new ClusterUnitPitchmarkGenerator();
107     }
108
109     /**
110      * Returns the unit concatenator to be used by this voice.
111      * Derived voices typically override this to customize behaviors.
112      * There is no default unit selector
113      * 
114      * @return the post lexical processor
115      * 
116      * @throws IOException if an IO error occurs while getting
117      *     processor
118      */
119     public UtteranceProcessor getUnitConcatenator() throws IOException {
120         return new UnitConcatenator();
121     }
122
123     
124     /**
125      * Converts this object to a string
126      * 
127      * @return a string representation of this object
128      */
129     public String toString() {
130         return "CMUClusterUnitVoice";
131     }
132 }