how to obtain the front end below
Data output = frontend.getData();
Calling {@link #getData() getData} on the front end would in turn call the getData() method on the lastDataProcessor, 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 {@link #setDataSource(edu.cmu.sphinx.frontend.DataProcessor) setDataSource} method to set itas the input DataProcessor. In that case, the input DataProcessor will be prepended to the existing chain of DataProcessors. One common input DataProcessor is the {@link edu.cmu.sphinx.frontend.util.Microphone}, which implements the DataProcessor interface.
DataProcessor microphone = new Microphone();
microphone.initialize(...);
frontend.setDataSource(microphone);
Another common input DataProcessor is the {@link edu.cmu.sphinx.frontend.util.StreamDataSource}. It turns a Java {@link java.io.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=" {@link edu.cmu.sphinx.frontend.filter.Preemphasizer edu.cmu.sphinx.frontend.filter.Preemphasizer}"/> <component name="windower" type=" {@link edu.cmu.sphinx.frontend.window.RaisedCosineWindower edu.cmu.sphinx.frontend.window.RaisedCosineWindower}"/> <component name="dft" type=" {@link edu.cmu.sphinx.frontend.transform.DiscreteFourierTransform edu.cmu.sphinx.frontend.transform.DiscreteFourierTransform}"/> <component name="melFilterBank" type=" {@link edu.cmu.sphinx.frontend.frequencywarp.MelFrequencyFilterBank2 edu.cmu.sphinx.frontend.frequencywarp.MelFrequencyFilterBank}"/> <component name="dct" type=" {@link edu.cmu.sphinx.frontend.transform.DiscreteCosineTransform edu.cmu.sphinx.frontend.transform.DiscreteCosineTransform}"/> <component name="batchCMN" type=" {@link edu.cmu.sphinx.frontend.feature.BatchCMN edu.cmu.sphinx.frontend.feature.BatchCMN}"/> <component name="featureExtractor" type=" {@link edu.cmu.sphinx.frontend.feature.DeltasFeatureExtractor edu.cmu.sphinx.frontend.feature.DeltasFeatureExtractor}"/>
Note: In this example, 'mfcFrontEnd' becomes the name of the front end.
Sphinx-4 also allows you to:
- specify multiple front end pipelines
- specify multiple instance of the same DataProcessor in the same pipeline
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 {@link edu.cmu.sphinx.util.props.Configurable#newProperties newProperties} method as follows:
public void newProperties(PropertySheet ps) throws PropertyException { FrontEnd frontend = (FrontEnd) ps.getComponent("frontend", FrontEnd.class); }