com.sun.speech.freetts
Class VoiceManager

java.lang.Object
  extended bycom.sun.speech.freetts.VoiceManager

public class VoiceManager
extends java.lang.Object

Provides access to voices for all of FreeTTS. There is only one instance of the VoiceManager. Each call to getVoices() creates a new instance of each voice.

See Also:
Voice, VoiceDirectory

Method Summary
 boolean contains(java.lang.String voiceName)
          Check if there is a voice provides with the given name.
static VoiceManager getInstance()
          Gets the instance of the VoiceManager
 Voice getVoice(java.lang.String voiceName)
          Get a Voice with a given name.
static java.net.URLClassLoader getVoiceClassLoader()
          Gets the class loader used for loading dynamically detected jars.
 java.lang.String getVoiceInfo()
          Prints detailed information about all available voices.
 Voice[] getVoices()
          Provide an array of all voices available to FreeTTS.
 java.lang.String toString()
          Provides a string representation of all voices available to FreeTTS.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getInstance

public static VoiceManager getInstance()
Gets the instance of the VoiceManager

Returns:
a VoiceManager

getVoices

public Voice[] getVoices()
Provide an array of all voices available to FreeTTS. First, if the "freetts.voices" property is set, it is assumed to be a comma-separated list of VoiceDirectory classnames (e.g., "-Dfreetts.voices=com.sun.speech.freetts.en.us.cmu_us_kal.KevinVoiceDirectory"). If this property exists, the VoiceManager will use only this property to find voices -- no other method described below will be used. The primary purpose for this property is testing and for use with WebStart.

Second, the file internal_voices.txt is looked for in the same directory as VoiceManager.class. If the file does not exist, the VoiceManager moves on. Next, it looks for voices.txt in the same directory as freetts.jar. If the file does not exist, the VoiceManager moves on. Next, if the property "freetts.voicesfile" is defined, then that file is read in. If the property is defined and the file does not exist, then an error is raised.

Every voices file that is read in contains a list of VoiceDirectory class names.

Next, the voice manager looks for freetts voice jarfiles that may exist in well-known locations. The directory that contains freetts.jar is searched for voice jarfiles, then directories specified by the "freetts.voicespath" system property. Any jarfile whose Manifest contains "FreeTTSVoiceDefinition: true" is assumed to be a FreeTTS voice, and the Manifest's "Main-Class" entry is assumed to be the name of the voice directory. The dependencies of the voice jarfiles specified by the "Class-Path" Manifest entry are also loaded.

The VoiceManager instantiates each voice directory and calls getVoices() on each.

Returns:
the array of new instances of all available voices

getVoiceInfo

public java.lang.String getVoiceInfo()
Prints detailed information about all available voices.

Returns:
a String containing the information

toString

public java.lang.String toString()
Provides a string representation of all voices available to FreeTTS.

Returns:
a String which is a space-delimited list of voice names. If there is more than one voice, then the word "or" appears before the last one.

contains

public boolean contains(java.lang.String voiceName)
Check if there is a voice provides with the given name.

Parameters:
voiceName - the name of the voice to check
Returns:
true if FreeTTS has a voice available with the name voiceName, else false.

getVoice

public Voice getVoice(java.lang.String voiceName)
Get a Voice with a given name.

Parameters:
voiceName - the name of the voice to get.
Returns:
the Voice that has the same name as voiceName if one exists, else null

getVoiceClassLoader

public static java.net.URLClassLoader getVoiceClassLoader()
Gets the class loader used for loading dynamically detected jars. This is useful to get resources out of jars that may be in the class path of this class loader but not in the class path of the system class loader.

Returns:
the class loader