public class StreamDataSource extends BaseDataProcessor
setInputStream
to set
the input stream, and call getData()
to obtain the Data object. The
InputStream can be an arbitrary stream, for example a data from the network
or from a pipe.
StreamDataSource is not aware about incoming data format and assumes
that incoming data matches StreamDataSource configuration. By default it's configured
to read 16 kHz little-endian 16-bit signed raw data. If data has wrong format
the result of the recognition is undefined. Also note that the sample rate of the
data must match the sample required by the the acoustic model. If your
model decodes 16 kHz files you can't recognize 8kHz data using it.
You can use AudioFileDataSource instead to read the file headers and
to convert incoming data to the required format automatically.Modifier and Type | Field and Description |
---|---|
protected int |
bitsPerSample |
static java.lang.String |
PROP_BIG_ENDIAN_DATA
The property specifying whether the input data is big-endian.
|
static java.lang.String |
PROP_BITS_PER_SAMPLE
The property for the number of bits per value.
|
static java.lang.String |
PROP_BYTES_PER_READ
The property for the number of bytes to read from the InputStream each
time.
|
static java.lang.String |
PROP_SAMPLE_RATE
The property for the sample rate.
|
static java.lang.String |
PROP_SIGNED_DATA
The property specifying whether the input data is signed.
|
protected int |
sampleRate |
logger
Constructor and Description |
---|
StreamDataSource() |
StreamDataSource(int sampleRate,
int bytesPerRead,
int bitsPerSample,
boolean bigEndian,
boolean signedData) |
Modifier and Type | Method and Description |
---|---|
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) |
void |
setInputStream(java.io.InputStream inputStream,
TimeFrame timeFrame)
Sets the InputStream from which this StreamDataSource reads.
|
getPredecessor, setPredecessor
getName, initLogger, toString
@S4Integer(defaultValue=16000) public static final java.lang.String PROP_SAMPLE_RATE
@S4Integer(defaultValue=3200) public static final java.lang.String PROP_BYTES_PER_READ
@S4Integer(defaultValue=16) public static final java.lang.String PROP_BITS_PER_SAMPLE
@S4Boolean(defaultValue=false) public static final java.lang.String PROP_BIG_ENDIAN_DATA
@S4Boolean(defaultValue=true) public static final java.lang.String PROP_SIGNED_DATA
protected int sampleRate
protected int bitsPerSample
public StreamDataSource(int sampleRate, int bytesPerRead, int bitsPerSample, boolean bigEndian, boolean signedData)
public StreamDataSource()
public void newProperties(PropertySheet ps) throws PropertyException
Configurable
newProperties
in interface Configurable
newProperties
in class ConfigurableAdapter
ps
- a property sheet holding the new dataPropertyException
- if there is a problem with the properties.public void initialize()
BaseDataProcessor
initialize
in interface DataProcessor
initialize
in class BaseDataProcessor
public void setInputStream(java.io.InputStream inputStream)
public void setInputStream(java.io.InputStream inputStream, TimeFrame timeFrame)
inputStream
- the InputStream from which audio data comestimeFrame
- time frame to processpublic Data getData() throws DataProcessingException
getData
in interface DataProcessor
getData
in class BaseDataProcessor
null
if none is availableDataProcessingException
- if there is a data processing error