edu.cmu.sphinx.frontend.util
Class StreamDataSource

java.lang.Object
  extended by edu.cmu.sphinx.frontend.BaseDataProcessor
      extended by edu.cmu.sphinx.frontend.util.StreamDataSource
All Implemented Interfaces:
DataProcessor, Configurable
Direct Known Subclasses:
ConcatFileDataSource

public class StreamDataSource
extends BaseDataProcessor

A StreamDataSource converts data from an InputStream into Data objects. One would call setInputStreamto set the input stream, and call getData()to obtain the Data object.


Field Summary
static java.lang.String PROP_BIG_ENDIAN_DATA
          The SphinxProperty specifying whether the input data is big-endian.
static boolean PROP_BIG_ENDIAN_DATA_DEFAULT
          The default value for PROP_IS_DATA_BIG_ENDIAN.
static java.lang.String PROP_BITS_PER_SAMPLE
          SphinxProperty for the number of bits per value.
static int PROP_BITS_PER_SAMPLE_DEFAULT
          Default value for PROP_BITS_PER_SAMPLE.
static java.lang.String PROP_BYTES_PER_READ
          SphinxProperty for the number of bytes to read from the InputStream each time.
static int PROP_BYTES_PER_READ_DEFAULT
          Default value for PROP_BYTES_PER_READ.
static java.lang.String PROP_SAMPLE_RATE
          SphinxProperty for the sample rate.
static int PROP_SAMPLE_RATE_DEFAULT
          Default value for PROP_SAMPLE_RATE.
static java.lang.String PROP_SIGNED_DATA
          The SphinxProperty specifying whether the input data is signed.
static boolean PROP_SIGNED_DATA_DEFAULT
          The default value of PROP_SIGNED_DATA.
 
Constructor Summary
StreamDataSource()
           
 
Method Summary
 Data getData()
          Reads and returns the next Data from the InputStream of StreamDataSource, return null if no data is read and end of file is reached.
 void initialize()
          Initializes this DataProcessor.
 void newProperties(PropertySheet ps)
          This method is called when this configurable component needs to be reconfigured.
 void setInputStream(java.io.InputStream inputStream, java.lang.String streamName)
          Sets the InputStream from which this StreamDataSource reads.
 
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_SAMPLE_RATE

@S4Integer(defaultValue=16000)
public static final java.lang.String PROP_SAMPLE_RATE
SphinxProperty for the sample rate.

See Also:
Constant Field Values

PROP_SAMPLE_RATE_DEFAULT

public static final int PROP_SAMPLE_RATE_DEFAULT
Default value for PROP_SAMPLE_RATE.

See Also:
Constant Field Values

PROP_BYTES_PER_READ

@S4Integer(defaultValue=3200)
public static final java.lang.String PROP_BYTES_PER_READ
SphinxProperty for the number of bytes to read from the InputStream each time.

See Also:
Constant Field Values

PROP_BYTES_PER_READ_DEFAULT

public static final int PROP_BYTES_PER_READ_DEFAULT
Default value for PROP_BYTES_PER_READ.

See Also:
Constant Field Values

PROP_BITS_PER_SAMPLE

@S4Integer(defaultValue=16)
public static final java.lang.String PROP_BITS_PER_SAMPLE
SphinxProperty for the number of bits per value.

See Also:
Constant Field Values

PROP_BITS_PER_SAMPLE_DEFAULT

public static final int PROP_BITS_PER_SAMPLE_DEFAULT
Default value for PROP_BITS_PER_SAMPLE.

See Also:
Constant Field Values

PROP_BIG_ENDIAN_DATA

@S4Boolean(defaultValue=true)
public static final java.lang.String PROP_BIG_ENDIAN_DATA
The SphinxProperty specifying whether the input data is big-endian.

See Also:
Constant Field Values

PROP_BIG_ENDIAN_DATA_DEFAULT

public static final boolean PROP_BIG_ENDIAN_DATA_DEFAULT
The default value for PROP_IS_DATA_BIG_ENDIAN.

See Also:
Constant Field Values

PROP_SIGNED_DATA

@S4Boolean(defaultValue=true)
public static final java.lang.String PROP_SIGNED_DATA
The SphinxProperty specifying whether the input data is signed.

See Also:
Constant Field Values

PROP_SIGNED_DATA_DEFAULT

public static final boolean PROP_SIGNED_DATA_DEFAULT
The default value of PROP_SIGNED_DATA.

See Also:
Constant Field Values
Constructor Detail

StreamDataSource

public StreamDataSource()
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

setInputStream

public void setInputStream(java.io.InputStream inputStream,
                           java.lang.String streamName)
Sets the InputStream from which this StreamDataSource reads.

Parameters:
inputStream - the InputStream from which audio data comes
streamName - the name of the InputStream

getData

public Data getData()
             throws DataProcessingException
Reads and returns the next Data from the InputStream of StreamDataSource, return null if no data is read and end of file is reached.

Specified by:
getData in interface DataProcessor
Specified by:
getData in class BaseDataProcessor
Returns:
the next Data or null if none is available
Throws:
DataProcessingException - if there is a data processing error