Class DiphoneUnitDatabase
The diphone data set is one of the largest sets of data that needs to be loaded by the synthesizer and therefore can add to the overall startup time for any system using this database. For certain applications, the startup time is a critical spec that needs to be optimized, while for other applications, startup time is inconsequential. This class provides settings (via system properties) that control how the database is to be loaded so that applications can tune for quick startup or optimal run time.
This class serves also as a testbed for comparing performance of
the traditional java binary I/O and the new io ( java.nio
)
package.
A diphone database can be loaded from a text data file, or a binary datafile. The binary version loads significantly faster than the text version. Additionally, a binary index can be generated and used to reduce overall memory footprint.
A DiphoneUnitDatabase contains an array of frames, and an aray of residuals. The frames are the samples of the wave, and the residuals are for linear predictive coding use. This is called "cst_sts" (a struct) in flite.
Note that if 'com.sun.speech.freetts.useNewIO' is set to true and the input type is binary, than the JDK1.4+ new IO api is used to load the database.
The system property
com.sun.speech.freetts.diphone.UnitDatabase.cacheTypecan be set to one of:
- preload: database is loaded at startup
- demand: database is loaded on demand
- hard: database is loaded on demand but cached
- soft: database is loaded on demand but cached with soft references
cacheType
setting controls how the database is
loaded. The default is to 'preload' the database. This setting
gives best runtime performance but with longer initial startup
cost.-
Constructor Summary
ConstructorsConstructorDescriptionDiphoneUnitDatabase
(URL url, boolean isBinary) Creates the DiphoneUnitDatabase from the given input stream. -
Method Summary
Modifier and TypeMethodDescriptionboolean
compare
(DiphoneUnitDatabase other) Compares this database to another.void
dump()
Dumps the diphone database.void
dumpBinary
(String path) Dumps a binary form of the database.getName()
Returns the name of this DiphoneUnitDatabase.Looks up the diphone with the given name.static void
Manipulates a DiphoneUnitDatabase.
-
Constructor Details
-
DiphoneUnitDatabase
Creates the DiphoneUnitDatabase from the given input stream.- Parameters:
url
- the location of the databaseisBinary
- iftrue
the database is in binary format; otherwise it is in text format- Throws:
IOException
- if there is trouble opening the DB
-
-
Method Details
-
getUnit
Looks up the diphone with the given name.- Parameters:
unitName
- the name of the diphone to look for- Returns:
- the diphone or the defaultDiphone if not found.
-
getName
Returns the name of this DiphoneUnitDatabase. -
dump
public void dump()Dumps the diphone database. -
dumpBinary
Dumps a binary form of the database.- Parameters:
path
- the path to dump the file to
-
compare
Compares this database to another. This is used for testing. With this method we can load up two databases (one perhaps from a text source and one from a binary source) and compare to verify that the dbs are identical- Parameters:
other
- the other database- Returns:
true
if the DBs are identical; otherwisefalse
-
main
Manipulates a DiphoneUnitDatabase. This program is typically used to generate the binary form (with index) of the DiphoneUnitDatabase from the text form. Additionally, this program can be used to compare two databases to see if they are identical (used for testing).Usage
java com.sun.speech.freetts.diphone.DiphoneUnitDatabase [options]
Options
-
-src path
provides a directory path to the source text for the database -
-dest path
provides a directory for where to place the resulting binaries -
-generate_binary [filename]
reads in the text version of the database and generates the binary version of the database. -
-compare
Loads the text and binary versions of the database and compares them to see if they are equivalent. -
-showTimes
shows timings for any loading, comparing or dumping operation
-
-