edu.cmu.sphinx.frontend
Class FrontEnd

java.lang.Object
  extended byedu.cmu.sphinx.frontend.BaseDataProcessor
      extended byedu.cmu.sphinx.frontend.FrontEnd
All Implemented Interfaces:
Configurable, DataProcessor

public class FrontEnd
extends BaseDataProcessor

FrontEnd is a wrapper class for the chain of front end processors. It provides methods for manipulating and navigating the processors.

The front end is modeled as a series of data processors, each of which performs a specific signal processing function. For example, a processor performs Fast-Fourier Transform (FFT) on input data, another processor performs high-pass filtering. Figure 1 below describes how the front end looks like:


Figure 1: The Sphinx4 front end.

Each such data processor implements the DataProcessor interface. Objects that implements the Data interface enters and exits the front end, and go between the processors in the front end. The input data to the front end is typically audio data, but this front end allows any input type. Similarly, the output data is typically features, but this front end allows any output type. You can configure the front end to accept any input type and return any output type. We will describe the configuration of the front end in more detail below.

The Pull Model of the Front End

The front end uses a pull model. To obtain output from the front end, one would call the method:

FrontEnd frontend = ... // see how to obtain the front end below
Data output = frontend.getData();

Calling getData on the front end would in turn call the getData() method on the last DataProcessor, which in turn calls the getData() method on the second last DataProcessor, and so on, until the getData() method on the first DataProcessor is called, which reads Data objects from the input. The input to the front end is actually another DataProcessor, and is usually (though not necessarily) part of the front end and is not shown in the figure above. If you want to maintain some control of the input DataProcessor, you can create it separately, and use the setDataSource method to set it as the input DataProcessor. In that case, the input DataProcessor will be prepended to the existing chain of DataProcessors. One common input DataProcessor is the Microphone, which implements the DataProcessor interface.

DataProcessor microphone = new Microphone();
microphone.initialize(...);
frontend.setDataSource(microphone);

Another common input DataProcessor is the StreamDataSource. It turns a Java InputStream into Data objects. It is usually used in batch mode decoding.

Configuring the front end

The front end must be configured through the Sphinx properties file. For details about configuring the front end, refer to the document Configuring the Front End. Current state-of-the-art front ends generate features that contain Mel-frequency cepstral coefficients (MFCC). To specify such a front end (called a 'pipeline') in Sphinx-4, insert the following lines in the Sphinx-4 configuration file:

 <component name="mfcFrontEnd" type="edu.cmu.sphinx.frontend.FrontEnd">
     <propertylist name="pipeline">
        <item>preemphasizer</item>
        <item>windower</item>
        <item>dft</item>
        <item>melFilterBank</item>
        <item>dct</item>
        <item>batchCMN</item>
        <item>featureExtractor</item>
     </propertylist>
 </component>

 <component name="preemphasizer" type="edu.cmu.sphinx.frontend.filter.Preemphasizer"/>
 <component name="windower" type="edu.cmu.sphinx.frontend.window.RaisedCosineWindower"/>
 <component name="dft" type="edu.cmu.sphinx.frontend.transform.DiscreteFourierTransform"/>
 <component name="melFilterBank" type="edu.cmu.sphinx.frontend.frequencywarp.MelFrequencyFilterBank"/>
 <component name="dct" type="edu.cmu.sphinx.frontend.transform.DiscreteCosineTransform"/>
 <component name="batchCMN" type="edu.cmu.sphinx.frontend.feature.BatchCMN"/>
 <component name="featureExtractor" type="edu.cmu.sphinx.frontend.feature.DeltasFeatureExtractor"/>
 

Note: In this example, 'mfcFrontEnd' becomes the name of the front end.

Sphinx-4 also allows you to:

For details on how to do this, refer to the document Configuring the Front End.

Obtaining a Front End

In order to obtain a front end, it must be specified in the configuration file. The Sphinx-4 front end is connected to the rest of the system via the scorer. We will continue with the above example to show how the scorer will obtain the front end. In the configuration file, the scorer should be specified as follows:

 <component name="scorer" type="edu.cmu.sphinx.decoder.scorer.SimpleAcousticScorer">
     <property name="frontend" value="mfcFrontEnd"/>
 </component>
 

In the SimpleAcousticScorer, the front end is obtained in the newProperties method as follows:

 public void newProperties(PropertySheet ps) throws PropertyException {
     FrontEnd frontend = (FrontEnd) ps.getComponent("frontend", FrontEnd.class);
 }
 


Field Summary
static java.lang.String PROP_PIPELINE
          the name of the property list of all the components of the frontend pipe line
 
Constructor Summary
FrontEnd()
           
 
Method Summary
 void addSignalListener(SignalListener listener)
          Add a listener to be called when a signal is detected.
 Data getData()
          Returns the processed Data output, basically calls getData() on the last processor.
 void initialize()
          Initializes this DataProcessor.
 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.
 void removeSignalListener(SignalListener listener)
          Removes a listener for signals.
 void setDataSource(DataProcessor dataSource)
          Sets the source of data for this front end.
 void setPredecessor(DataProcessor dataSource)
          Sets the source of data for this front end.
 java.lang.String toString()
          Returns a description of this FrontEnd in the format: {, ...
 
Methods inherited from class edu.cmu.sphinx.frontend.BaseDataProcessor
getName, getPredecessor, getTimer
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROP_PIPELINE

public static final java.lang.String PROP_PIPELINE
the name of the property list of all the components of the frontend pipe line

See Also:
Constant Field Values
Constructor Detail

FrontEnd

public FrontEnd()
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
Overrides:
register in class BaseDataProcessor
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
Overrides:
newProperties in class BaseDataProcessor
Throws:
PropertyException

initialize

public void initialize()
Description copied from class: BaseDataProcessor
Initializes this DataProcessor. This is typically called after the DataProcessor has been configured.

Specified by:
initialize in interface DataProcessor
Overrides:
initialize in class BaseDataProcessor

setDataSource

public void setDataSource(DataProcessor dataSource)
Sets the source of data for this front end. It basically sets the predecessor of the first DataProcessor of this front end.

Parameters:
dataSource - the source of data

getData

public Data getData()
             throws DataProcessingException
Returns the processed Data output, basically calls getData() on the last processor.

Specified by:
getData in interface DataProcessor
Specified by:
getData in class BaseDataProcessor
Returns:
an Data object that has been processed by this front end
Throws:
DataProcessingException - if a data processor error occurs

setPredecessor

public void setPredecessor(DataProcessor dataSource)
Sets the source of data for this front end. It basically calls setDataSource(dataSource).

Specified by:
setPredecessor in interface DataProcessor
Overrides:
setPredecessor in class BaseDataProcessor
Parameters:
dataSource - the source of data

addSignalListener

public void addSignalListener(SignalListener listener)
Add a listener to be called when a signal is detected.

Parameters:
listener - the listener to be added

removeSignalListener

public void removeSignalListener(SignalListener listener)
Removes a listener for signals.

Parameters:
listener - the listener to be removed

toString

public java.lang.String toString()
Returns a description of this FrontEnd in the format: {, ... }

Overrides:
toString in class BaseDataProcessor
Returns:
a description of this FrontEnd