edu.cmu.sphinx.linguist.acoustic.tiedstate
Class Sphinx3Loader

java.lang.Object
  extended byedu.cmu.sphinx.linguist.acoustic.tiedstate.Sphinx3Loader
All Implemented Interfaces:
Configurable, Loader

public class Sphinx3Loader
extends java.lang.Object
implements Loader

Loads a tied-state acoustic model generated by the Sphinx-3 trainer.

The acoustic model should be packaged in a JAR file. The dictionary and language model files are not required to be in the package. You can specify their locations separately. A text file called "model.props" and the data files that make up the acoustic model are required. The model.props file is a file of key-value pairs, loadable as a Java Properties file. It should minimally contain the following properties:

The actual model data files are named "means", "variances", "transition_matrices", "mixture_weights" for binary versions, or prepended with ".ascii" for the ASCII versions.

As an example, lets look at the Wall Street Journal acoustic model JAR file, which is located at the sphinx4/lib directory. If you run "jar tvf lib/WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.jar", you will find that its internal structure looks roughly like:

 WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.jar
   |
   +- edu
       |
       +- cmu
           |
           +- sphinx
               |
               +- model
                   |
                   + acoustic
                      |
                      +- model.props
                      |
                      +- WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.class
                      |
                      +- WSJLoader.class
                      |
                      +- cd_continuous_8gau
                      |   |
                      |   +- means
                      |   +- variances
                      |   +- mixture_weights
                      |   +- transition_matrices
                      |
                      +- dict
                      |   |
                      |   +- alpha.dict
                      |   +- cmudict.0.6d
                      |   +- digits.dict
                      |   +- fillerdict
                      |
                      +- etc
                          |
                          +- WSJ_clean_13dCep_16k_40mel_130Hz_6800Hz.4000.mdef
                          +- WSJ_clean_13dCep_16k_40mel_130Hz_6800Hz.ci.mdef
                          +- variables.def

 

The model.props file looks like (note how the 'dataLocation' and 'modelDefinition' properties are defined relative to the WSJ_clean_13dCep_16k_40mel_130Hz_6800Hz.class):

description = Wall Street Journal acoustic models

isBinary = true
featureType = cepstra_delta_doubledelta
vectorLength = 39
sparseForm = false

numberFftPoints = 512
filters = 40
gaussians = 8
maxFreq = 6800
minFreq. = 130
sampleRate = 16000

dataLocation = cd_continuous_8gau
modelDefinition = etc/WSJ_clean_13dCep_16k_40mel_130Hz_6800Hz.4000.mdef
 

Note that although most of the properties of this class are already defined in the model.props file, it is still possible (but not recommended) to override those values by specifying them in the configuration file.


Field Summary
static java.lang.String MODEL_VERSION
          Supports this version of the acoustic model
static java.lang.String PROP_DATA_LOCATION
          Subdirectory where the acoustic model can be found
static java.lang.String PROP_DATA_LOCATION_DEFAULT
          The default value of PROP_DATA_LOCATION.
static java.lang.String PROP_IS_BINARY
          Specifies whether the model to be loaded is in ASCII or binary format
static boolean PROP_IS_BINARY_DEFAULT
          The default value of PROP_IS_BINARY
static java.lang.String PROP_LOG_MATH
          The log math component for the system.
static java.lang.String PROP_MC_FLOOR
          Mixture component score floor.
static float PROP_MC_FLOOR_DEFAULT
          Mixture component score floor default value.
static java.lang.String PROP_MODEL
          The name of the model definition file (contains the HMM data)
static java.lang.String PROP_MODEL_DEFAULT
          The default value of PROP_MODEL_DEFAULT.
static java.lang.String PROP_MW_FLOOR
          Mixture weight floor.
static float PROP_MW_FLOOR_DEFAULT
          Mixture weight floor default value.
static java.lang.String PROP_PROPERTIES_FILE
          The SphinxProperty for the name of the acoustic properties file.
static java.lang.String PROP_PROPERTIES_FILE_DEFAULT
          The default value of PROP_PROPERTIES_FILE.
static java.lang.String PROP_SPARSE_FORM
          The SphinxProperty specifying whether the transition matrices of the acoustic model is in sparse form, i.e., omitting the zeros of the non-transitioning states.
static boolean PROP_SPARSE_FORM_DEFAULT
          The default value of PROP_SPARSE_FORM.
static java.lang.String PROP_UNIT_MANAGER
          The unit manager
static java.lang.String PROP_USE_CD_UNITS
          The SphinxProperty specifying whether context-dependent units should be used.
static boolean PROP_USE_CD_UNITS_DEFAULT
          The default value of PROP_USE_CD_UNITS.
static java.lang.String PROP_VARIANCE_FLOOR
          Variance floor.
static float PROP_VARIANCE_FLOOR_DEFAULT
          Variance floor default value.
static java.lang.String PROP_VECTOR_LENGTH
          The SphinxProperty for the length of feature vectors.
static int PROP_VECTOR_LENGTH_DEFAULT
          The default value of PROP_VECTOR_LENGTH.
 
Constructor Summary
Sphinx3Loader()
           
 
Method Summary
 java.util.Map getContextIndependentUnits()
          Returns the map of context indepent units.
 HMMManager getHMMManager()
          Returns the hmm manager associated with this loader
 int getLeftContextSize()
          Returns the size of the left context for context dependent units
 Pool getMeansPool()
          Gets the pool of means for this loader
 Pool getMeansTransformationMatrixPool()
          Gets the pool of means transformation matrices for this loader
 Pool getMeansTransformationVectorPool()
          Gets the pool of means transformation vectors for this loader
 Pool getMixtureWeightPool()
          Gets the mixture weight pool
 java.lang.String getName()
          Retrieves the name for this configurable component
 int getRightContextSize()
          Returns the size of the right context for context dependent units
 Pool getSenonePool()
          Gets the senone pool for this loader
 Pool getTransitionMatrixPool()
          Gets the transition matrix pool
 Pool getVariancePool()
          Gets the variance pool
 Pool getVarianceTransformationMatrixPool()
          Gets the variance transformation matrix pool
 Pool getVarianceTransformationVectorPool()
          Gets the pool of variance transformation vectors for this loader
 void load()
          Loads the acoustic model
 void logInfo()
          Log info about this loader
 void newProperties(PropertySheet ps)
          This method is called when this configurable component has new data.
 void register(java.lang.String name, Registry registry)
          Register my properties.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_LOG_MATH

public static final java.lang.String PROP_LOG_MATH
The log math component for the system.

See Also:
Constant Field Values

PROP_UNIT_MANAGER

public static final java.lang.String PROP_UNIT_MANAGER
The unit manager

See Also:
Constant Field Values

PROP_IS_BINARY

public static final java.lang.String PROP_IS_BINARY
Specifies whether the model to be loaded is in ASCII or binary format

See Also:
Constant Field Values

PROP_IS_BINARY_DEFAULT

public static final boolean PROP_IS_BINARY_DEFAULT
The default value of PROP_IS_BINARY

See Also:
Constant Field Values

PROP_MODEL

public static final java.lang.String PROP_MODEL
The name of the model definition file (contains the HMM data)

See Also:
Constant Field Values

PROP_MODEL_DEFAULT

public static final java.lang.String PROP_MODEL_DEFAULT
The default value of PROP_MODEL_DEFAULT.

See Also:
Constant Field Values

PROP_DATA_LOCATION

public static final java.lang.String PROP_DATA_LOCATION
Subdirectory where the acoustic model can be found

See Also:
Constant Field Values

PROP_DATA_LOCATION_DEFAULT

public static final java.lang.String PROP_DATA_LOCATION_DEFAULT
The default value of PROP_DATA_LOCATION.

See Also:
Constant Field Values

PROP_PROPERTIES_FILE

public static final java.lang.String PROP_PROPERTIES_FILE
The SphinxProperty for the name of the acoustic properties file.

See Also:
Constant Field Values

PROP_PROPERTIES_FILE_DEFAULT

public static final java.lang.String PROP_PROPERTIES_FILE_DEFAULT
The default value of PROP_PROPERTIES_FILE.

See Also:
Constant Field Values

PROP_VECTOR_LENGTH

public static final java.lang.String PROP_VECTOR_LENGTH
The SphinxProperty for the length of feature vectors.

See Also:
Constant Field Values

PROP_VECTOR_LENGTH_DEFAULT

public static final int PROP_VECTOR_LENGTH_DEFAULT
The default value of PROP_VECTOR_LENGTH.

See Also:
Constant Field Values

PROP_SPARSE_FORM

public static final java.lang.String PROP_SPARSE_FORM
The SphinxProperty specifying whether the transition matrices of the acoustic model is in sparse form, i.e., omitting the zeros of the non-transitioning states.

See Also:
Constant Field Values

PROP_SPARSE_FORM_DEFAULT

public static final boolean PROP_SPARSE_FORM_DEFAULT
The default value of PROP_SPARSE_FORM.

See Also:
Constant Field Values

PROP_USE_CD_UNITS

public static final java.lang.String PROP_USE_CD_UNITS
The SphinxProperty specifying whether context-dependent units should be used.

See Also:
Constant Field Values

PROP_USE_CD_UNITS_DEFAULT

public static final boolean PROP_USE_CD_UNITS_DEFAULT
The default value of PROP_USE_CD_UNITS.

See Also:
Constant Field Values

PROP_MC_FLOOR

public static final java.lang.String PROP_MC_FLOOR
Mixture component score floor.

See Also:
Constant Field Values

PROP_MC_FLOOR_DEFAULT

public static final float PROP_MC_FLOOR_DEFAULT
Mixture component score floor default value.

See Also:
Constant Field Values

PROP_VARIANCE_FLOOR

public static final java.lang.String PROP_VARIANCE_FLOOR
Variance floor.

See Also:
Constant Field Values

PROP_VARIANCE_FLOOR_DEFAULT

public static final float PROP_VARIANCE_FLOOR_DEFAULT
Variance floor default value.

See Also:
Constant Field Values

PROP_MW_FLOOR

public static final java.lang.String PROP_MW_FLOOR
Mixture weight floor.

See Also:
Constant Field Values

PROP_MW_FLOOR_DEFAULT

public static final float PROP_MW_FLOOR_DEFAULT
Mixture weight floor default value.

See Also:
Constant Field Values

MODEL_VERSION

public static final java.lang.String MODEL_VERSION
Supports this version of the acoustic model

See Also:
Constant Field Values
Constructor Detail

Sphinx3Loader

public Sphinx3Loader()
Method Detail

register

public void register(java.lang.String name,
                     Registry registry)
              throws PropertyException
Description copied from interface: Configurable
Register my properties. This method is called once early in the time of the component, shortly after the component is constructed. This component should register any configuration properties that it needs to register. If this configurable extends another configurable, super.register should also be called

Specified by:
register in interface Configurable
Parameters:
name - the name of the component
registry - the registry for this component
Throws:
PropertyException

newProperties

public void newProperties(PropertySheet ps)
                   throws PropertyException
Description copied from interface: Configurable
This method is called when this configurable component has new data. The component should first validate the data. If it is bad the component should return false. If the data is good, the component should record the the data internally and return true.

Specified by:
newProperties in interface Configurable
Parameters:
ps - a property sheet holding the new data
Throws:
PropertyException - if there is a problem with the properties.

getName

public java.lang.String getName()
Description copied from interface: Configurable
Retrieves the name for this configurable component

Specified by:
getName in interface Configurable
Returns:
the name

load

public void load()
          throws java.io.IOException
Description copied from interface: Loader
Loads the acoustic model

Specified by:
load in interface Loader
Throws:
java.io.IOException - if an error occurs while loading the model

getContextIndependentUnits

public java.util.Map getContextIndependentUnits()
Returns the map of context indepent units. The map can be accessed by unit name.

Specified by:
getContextIndependentUnits in interface Loader
Returns:
the map of context independent units.

getMeansPool

public Pool getMeansPool()
Gets the pool of means for this loader

Specified by:
getMeansPool in interface Loader
Returns:
the pool

getMeansTransformationMatrixPool

public Pool getMeansTransformationMatrixPool()
Gets the pool of means transformation matrices for this loader

Specified by:
getMeansTransformationMatrixPool in interface Loader
Returns:
the pool

getMeansTransformationVectorPool

public Pool getMeansTransformationVectorPool()
Gets the pool of means transformation vectors for this loader

Specified by:
getMeansTransformationVectorPool in interface Loader
Returns:
the pool

getVariancePool

public Pool getVariancePool()
Description copied from interface: Loader
Gets the variance pool

Specified by:
getVariancePool in interface Loader
Returns:
the pool

getVarianceTransformationMatrixPool

public Pool getVarianceTransformationMatrixPool()
Gets the variance transformation matrix pool

Specified by:
getVarianceTransformationMatrixPool in interface Loader
Returns:
the pool

getVarianceTransformationVectorPool

public Pool getVarianceTransformationVectorPool()
Gets the pool of variance transformation vectors for this loader

Returns:
the pool

getMixtureWeightPool

public Pool getMixtureWeightPool()
Description copied from interface: Loader
Gets the mixture weight pool

Specified by:
getMixtureWeightPool in interface Loader
Returns:
the pool

getTransitionMatrixPool

public Pool getTransitionMatrixPool()
Description copied from interface: Loader
Gets the transition matrix pool

Specified by:
getTransitionMatrixPool in interface Loader
Returns:
the pool

getSenonePool

public Pool getSenonePool()
Description copied from interface: Loader
Gets the senone pool for this loader

Specified by:
getSenonePool in interface Loader
Returns:
the pool

getLeftContextSize

public int getLeftContextSize()
Returns the size of the left context for context dependent units

Specified by:
getLeftContextSize in interface Loader
Returns:
the left context size

getRightContextSize

public int getRightContextSize()
Returns the size of the right context for context dependent units

Specified by:
getRightContextSize in interface Loader
Returns:
the left context size

getHMMManager

public HMMManager getHMMManager()
Returns the hmm manager associated with this loader

Specified by:
getHMMManager in interface Loader
Returns:
the hmm Manager

logInfo

public void logInfo()
Log info about this loader

Specified by:
logInfo in interface Loader