com.sun.speech.freetts.diphone
Class DiphoneUnitDatabase

java.lang.Object
  extended bycom.sun.speech.freetts.diphone.DiphoneUnitDatabase

public class DiphoneUnitDatabase
extends java.lang.Object

Represents and manages the unit data for all diphones. The diphone data set is stored in a set of data files. These data are loaded by this class into internal data structures before diphone synthesis can occur.

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.cacheType 
 
can be set to one of: This 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
DiphoneUnitDatabase(java.net.URL url, boolean isBinary)
          Creates the DiphoneUnitDatabase from the given input stream.
 
Method Summary
 boolean compare(DiphoneUnitDatabase other)
          Compares this database to another.
 void dump()
          Dumps the diphone database.
 void dumpBinary(java.lang.String path)
          Dumps a binary form of the database.
 java.lang.String getName()
          Returns the name of this DiphoneUnitDatabase.
 Diphone getUnit(java.lang.String unitName)
          Looks up the diphone with the given name.
static void main(java.lang.String[] args)
          Manipulates a DiphoneUnitDatabase.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DiphoneUnitDatabase

public DiphoneUnitDatabase(java.net.URL url,
                           boolean isBinary)
                    throws java.io.IOException
Creates the DiphoneUnitDatabase from the given input stream.

Parameters:
url - the location of the database
isBinary - if true the database is in binary format; otherwise it is in text format
Throws:
java.io.IOException - if there is trouble opening the DB
Method Detail

getUnit

public Diphone getUnit(java.lang.String unitName)
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

public java.lang.String getName()
Returns the name of this DiphoneUnitDatabase.


dump

public void dump()
Dumps the diphone database.


dumpBinary

public void dumpBinary(java.lang.String path)
Dumps a binary form of the database.

Parameters:
path - the path to dump the file to

compare

public boolean compare(DiphoneUnitDatabase other)
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; otherwise false

main

public static void main(java.lang.String[] args)
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