public class VoiceManager extends Object
Voice
,
VoiceDirectory
Modifier and Type | Field and Description |
---|---|
private static DynamicClassLoader |
classLoader
we only want one class loader, otherwise the static information for
loaded classes would be duplicated for each class loader
|
private static VoiceManager |
INSTANCE |
private static String |
PATH_SEPARATOR |
Modifier | Constructor and Description |
---|---|
private |
VoiceManager()
Do not allow creation from outside.
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(String voiceName)
Check if there is a voice provides with the given name.
|
private String |
getBaseDirectory()
Get the directory that the jar file containing this class resides in.
|
private void |
getDependencyURLs(URL url,
UniqueVector<URL> dependencyURLs)
Recursively gets the urls of the class paths that url is dependant on.
|
static VoiceManager |
getInstance()
Gets the instance of the VoiceManager
|
private String |
getURLDirName(URL url)
Gets the directory name from a URL
|
Voice |
getVoice(String voiceName)
Get a Voice with a given name.
|
static URLClassLoader |
getVoiceClassLoader()
Gets the class loader used for loading dynamically detected jars.
|
private Collection<VoiceDirectory> |
getVoiceDirectories()
Creates an array of all voice directories of all available voices using
the criteria specified by the contract for getVoices().
|
private UniqueVector<String> |
getVoiceDirectoryNamesFromFile(String fileName)
Get the names of the voice directories from a voices file.
|
private UniqueVector<String> |
getVoiceDirectoryNamesFromFiles()
Gets the names of the subclasses of VoiceDirectory that are listed in the
voices.txt files.
|
private UniqueVector<String> |
getVoiceDirectoryNamesFromInputStream(InputStream is)
Get the names of the voice directories from an input stream.
|
private UniqueVector<String> |
getVoiceDirectoryNamesFromJarURLs(UniqueVector<URL> urls)
Gets the voice directory class names from a list of urls specifying voice
jarfiles.
|
private Collection<VoiceDirectory> |
getVoiceDirectoryNamesFromProperty(String voiceClasses)
Gets VoiceDirectory instances by parsing a comma separated String of
VoiceDirectory class names.
|
String |
getVoiceInfo()
Prints detailed information about all available voices.
|
private UniqueVector<URL> |
getVoiceJarURLs()
Gets the list of voice jarfiles.
|
private UniqueVector<URL> |
getVoiceJarURLsFromDir(String dirName)
Gets the list of voice jarfiles in a specific directory.
|
Voice[] |
getVoices()
Provide an array of all voices available to FreeTTS.
|
String |
toString()
Provides a string representation of all voices available to FreeTTS.
|
private static final VoiceManager INSTANCE
private static final String PATH_SEPARATOR
private static final DynamicClassLoader classLoader
private VoiceManager()
public static VoiceManager getInstance()
public Voice[] getVoices()
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.
public String getVoiceInfo()
private Collection<VoiceDirectory> getVoiceDirectories() throws IOException
IOException
- error loading a voice directorygetVoices()
private Collection<VoiceDirectory> getVoiceDirectoryNamesFromProperty(String voiceClasses) throws InstantiationException, IllegalAccessException, ClassNotFoundException
private void getDependencyURLs(URL url, UniqueVector<URL> dependencyURLs) throws IOException
url
- the url to recursively check. If it ends with a "/" then it is
presumed to be a directory, and is not checked. Otherwise it
is assumed to be a jar, and its manifest is read to get the
urls Class-Path entry. These urls are passed to this method
recursively.dependencyURLs
- a vector containing all of the dependent urls found. This
parameter is modified as urls are added to it.IOException
- error openig the URL connectionprivate UniqueVector<String> getVoiceDirectoryNamesFromFiles() throws IOException
IOException
- error reading voice files.private UniqueVector<String> getVoiceDirectoryNamesFromJarURLs(UniqueVector<URL> urls)
urls
- a UniqueVector of URLs that refer to the voice jarfilesprivate UniqueVector<URL> getVoiceJarURLs()
private UniqueVector<URL> getVoiceJarURLsFromDir(String dirName) throws FileNotFoundException
FileNotFoundException
getVoiceJarURLs()
public String toString()
public boolean contains(String voiceName)
voiceName
- the name of the voice to checkpublic Voice getVoice(String voiceName)
voiceName
- the name of the voice to get.private String getBaseDirectory()
private String getURLDirName(URL url)
url
- the url to parseprivate UniqueVector<String> getVoiceDirectoryNamesFromFile(String fileName) throws FileNotFoundException, IOException
fileName
- the name of the voices file to read fromFileNotFoundException
IOException
private UniqueVector<String> getVoiceDirectoryNamesFromInputStream(InputStream is) throws IOException
is
- the input stream to read fromIOException
- error reading from the input streampublic static URLClassLoader getVoiceClassLoader()
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses