001/** 002 * Portions Copyright 2001 Sun Microsystems, Inc. 003 * Portions Copyright 1999-2001 Language Technologies Institute, 004 * Carnegie Mellon University. 005 * All Rights Reserved. Use is subject to license terms. 006 * 007 * See the file "license.terms" for information on usage and 008 * redistribution of this file, and for a DISCLAIMER OF ALL 009 * WARRANTIES. 010 */ 011package com.sun.speech.freetts.en.us; 012 013import java.io.IOException; 014import java.net.URL; 015import java.util.Locale; 016 017import com.sun.speech.freetts.Age; 018import com.sun.speech.freetts.Gender; 019import com.sun.speech.freetts.UtteranceProcessor; 020import com.sun.speech.freetts.clunits.ClusterUnitPitchmarkGenerator; 021import com.sun.speech.freetts.clunits.ClusterUnitSelector; 022import com.sun.speech.freetts.relp.UnitConcatenator; 023 024import de.dfki.lt.freetts.ConcatenativeVoice; 025 026/** 027 * Defines voice that does cluster unit selection. 028 */ 029public class CMUClusterUnitVoice extends CMUVoice implements ConcatenativeVoice { 030 031 protected URL database; 032 033 /** 034 * Creates a simple cluster unit voice 035 * 036 * @param name the name of the voice 037 * @param gender the gender of the voice 038 * @param age the age of the voice 039 * @param description a human-readable string providing a 040 * description that can be displayed for the users. 041 * @param locale the locale of the voice 042 * @param domain the domain of this voice. For example, 043 * @param organization the organization which created the voice 044 * "general", "time", or 045 * "weather". 046 * @param lexicon the lexicon to load 047 * @param database the url to the database containing unit data 048 * for this voice. 049 */ 050 public CMUClusterUnitVoice(String name, Gender gender, Age age, 051 String description, Locale locale, String domain, 052 String organization, CMULexicon lexicon, URL database) { 053 super(name, gender, age, description, locale, 054 domain, organization, lexicon); 055 setRate(150f); 056 setPitch(100F); 057 setPitchRange(12F); 058 this.database = database; 059 } 060 061 /** 062 * Gets the url to the database that defines the unit data for this 063 * voice. 064 * 065 * @return a url to the database 066 */ 067 public URL getDatabase() { 068 return database; 069 } 070 071 /** 072 * Sets up the FeatureSet for this Voice. 073 * 074 * @throws IOException if an I/O error occurs 075 */ 076 protected void setupFeatureSet() throws IOException { 077 super.setupFeatureSet(); 078 getFeatures().setString(FEATURE_JOIN_TYPE, "simple_join"); 079 } 080 081 /** 082 * Returns the unit selector to be used by this voice. 083 * Derived voices typically override this to customize behaviors. 084 * This voice uses a cluster unit selector as the unit selector. 085 * 086 * @return the post lexical processor 087 * 088 * @throws IOException if an IO error occurs while getting 089 * processor 090 */ 091 public UtteranceProcessor getUnitSelector() throws IOException { 092 return new ClusterUnitSelector(getDatabase()); 093 } 094 095 /** 096 * Returns the pitch mark generator to be used by this voice. 097 * Derived voices typically override this to customize behaviors. 098 * There is no default unit selector 099 * 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}