edu.cmu.sphinx.frontend.util
Class StreamDataSource

java.lang.Object
  extended byedu.cmu.sphinx.frontend.BaseDataProcessor
      extended byedu.cmu.sphinx.frontend.util.StreamDataSource
All Implemented Interfaces:
Configurable, DataProcessor
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 has new data.
 void register(java.lang.String name, Registry registry)
          Register my properties.
 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
getName, getPredecessor, getTimer, setPredecessor, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROP_SAMPLE_RATE

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

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

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

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

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

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

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