edu.cmu.sphinx.frontend.window
Class RaisedCosineWindower

java.lang.Object
  extended by edu.cmu.sphinx.frontend.BaseDataProcessor
      extended by edu.cmu.sphinx.frontend.window.RaisedCosineWindower
All Implemented Interfaces:
DataProcessor, Configurable

public class RaisedCosineWindower
extends BaseDataProcessor

Slices up a Data object into a number of overlapping windows (usually refered to as "frames" in the speech world). In order to minimize the signal discontinuities at the boundaries of each frame, we multiply each frame with a raised cosine windowing function. Moreover, the system uses overlapping windows to capture information that may occur at the window boundaries. These events would not be well represented if the windows were juxtaposed.

The number of resulting windows depends on the window size and the window shift (commonly known as frame shift in speech world). Figure 1 shows the relationship between the original data stream, the window size, the window shift, and the windows returned.


Figure 1: Relationship between original data, window size, window shift, and the windows returned.

The raised cosine windowing function will be applied to each such window. Since the getData() method returns a window, and multiple windows are created for each Data object, this is a 1-to-many processor. Also note that the returned windows should have the same number of data points as the windowing function.

The applied windowing function, W(n), of length N (the window size), is given by the following formula:

 W(n) = (1-a) - (a * cos((2 * Math.PI * n)/(N - 1)))
 
where a is commonly known as the "alpha" value. This variable can be set by the user using the property defined by PROP_ALPHA. Please follow the links to the see the constant field values. Some values of alpha receive special names, since they are used so often. A value of 0.46 for the alpha results in a window named Hamming window. A value of 0.5 results in the Hanning window. And a value of 0 results in the Rectangular window. The default for this system is the Hamming window, with alpha 0.46 !). Figure 2 below shows the Hamming window function (a = 0.46), using our default window size of 25.625 ms and assuming a sample rate of 16kHz, thus yielding 410 samples per window.


Figure 2: The Hamming window function.

See Also:
Data

Field Summary
static java.lang.String PROP_ALPHA
          The name of the SphinxProperty for the alpha value of the Window, which is the value for the RaisedCosineWindow.
static java.lang.String PROP_WINDOW_SHIFT_MS
          The SphinxProperty name for window shift in milliseconds, which has a default value of 10F.
static java.lang.String PROP_WINDOW_SIZE_MS
          The SphinxProperty name for window size in milliseconds.
static java.lang.String WINDOW_SHIFT_SAMPLES
           
static java.lang.String WINDOW_SIZE_SAMPLES
           
 
Constructor Summary
RaisedCosineWindower()
           
 
Method Summary
 Data getData()
          Returns the next Data object, which is usually a window of the input Data, with the windowing function applied to it.
 int getSampleRate()
           
 float getWindowShiftInMs()
          Returns the shift size used to window the incoming speech signal.
 void initialize()
          Initializes this DataProcessor.
 void newProperties(PropertySheet ps)
          This method is called when this configurable component needs to be reconfigured.
 long roundToFrames(long samples)
          Rounds a given sample-number to the number of samples will be processed by this instance including the padding samples at the end..
 
Methods inherited from class edu.cmu.sphinx.frontend.BaseDataProcessor
getPredecessor, getTimer, setPredecessor, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROP_WINDOW_SIZE_MS

@S4Double(defaultValue=25.625)
public static final java.lang.String PROP_WINDOW_SIZE_MS
The SphinxProperty name for window size in milliseconds.

See Also:
Constant Field Values

PROP_WINDOW_SHIFT_MS

@S4Double(defaultValue=10.0)
public static final java.lang.String PROP_WINDOW_SHIFT_MS
The SphinxProperty name for window shift in milliseconds, which has a default value of 10F.

See Also:
Constant Field Values

PROP_ALPHA

@S4Double(defaultValue=0.46)
public static final java.lang.String PROP_ALPHA
The name of the SphinxProperty for the alpha value of the Window, which is the value for the RaisedCosineWindow.

See Also:
Constant Field Values

WINDOW_SHIFT_SAMPLES

public static final java.lang.String WINDOW_SHIFT_SAMPLES
See Also:
Constant Field Values

WINDOW_SIZE_SAMPLES

public static final java.lang.String WINDOW_SIZE_SAMPLES
See Also:
Constant Field Values
Constructor Detail

RaisedCosineWindower

public RaisedCosineWindower()
Method Detail

newProperties

public void newProperties(PropertySheet ps)
                   throws PropertyException
Description copied from interface: Configurable
This method is called when this configurable component needs to be reconfigured.

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

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

getData

public Data getData()
             throws DataProcessingException
Returns the next Data object, which is usually a window of the input Data, with the windowing function applied to it.

Specified by:
getData in interface DataProcessor
Specified by:
getData in class BaseDataProcessor
Returns:
the next available Data object, returns null if no Data object is available
Throws:
DataProcessingException - if a data processing error occurred
See Also:
Data

getWindowShiftInMs

public float getWindowShiftInMs()
Returns the shift size used to window the incoming speech signal. This value might be used by other components to determine the time resolution of feature vectors.


getSampleRate

public int getSampleRate()

roundToFrames

public long roundToFrames(long samples)
Rounds a given sample-number to the number of samples will be processed by this instance including the padding samples at the end..