Package edu.cmu.sphinx.frontend.util
Class SegmentStorer
java.lang.Object
edu.cmu.sphinx.util.props.ConfigurableAdapter
edu.cmu.sphinx.frontend.BaseDataProcessor
edu.cmu.sphinx.frontend.util.SegmentStorer
- All Implemented Interfaces:
edu.cmu.sphinx.frontend.DataProcessor,edu.cmu.sphinx.util.props.Configurable
public class SegmentStorer
extends edu.cmu.sphinx.frontend.BaseDataProcessor
Stores audio data into numbered (MS-)wav files.
TODO: currently the WavWriter buffers all audio data until a DataEndSignal occurs.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanstatic final StringThe property for the number of bits per value.static final StringThe property specifying whether the input data is signed.Fields inherited from class edu.cmu.sphinx.util.props.ConfigurableAdapter
logger -
Constructor Summary
ConstructorsConstructorDescriptionSegmentStorer(String dumpFilePath, boolean isCompletePath, int bitsPerSample, boolean isSigned) -
Method Summary
Modifier and TypeMethodDescriptionedu.cmu.sphinx.frontend.DatagetData()longgetEndTime(int index) byte[]getSegment(int index) longgetStartTime(int index) voidInitializes this DataProcessor.voidnewProperties(edu.cmu.sphinx.util.props.PropertySheet ps) protected voidstatic byte[]valuesToBytes(double[] values, int bytesPerValue, boolean signedData) Converts a big-endian byte array into an array of doubles.Methods inherited from class edu.cmu.sphinx.frontend.BaseDataProcessor
getPredecessor, setPredecessorMethods inherited from class edu.cmu.sphinx.util.props.ConfigurableAdapter
getName, initLogger, toString
-
Field Details
-
PROP_BITS_PER_SAMPLE
The property for the number of bits per value.- See Also:
-
PROP_SIGNED_DATA
The property specifying whether the input data is signed.- See Also:
-
captureUtts
protected boolean captureUtts
-
-
Constructor Details
-
SegmentStorer
public SegmentStorer(String dumpFilePath, boolean isCompletePath, int bitsPerSample, boolean isSigned) -
SegmentStorer
public SegmentStorer()
-
-
Method Details
-
newProperties
public void newProperties(edu.cmu.sphinx.util.props.PropertySheet ps) throws edu.cmu.sphinx.util.props.PropertyException - Specified by:
newPropertiesin interfaceedu.cmu.sphinx.util.props.Configurable- Overrides:
newPropertiesin classedu.cmu.sphinx.util.props.ConfigurableAdapter- Throws:
edu.cmu.sphinx.util.props.PropertyException
-
getData
public edu.cmu.sphinx.frontend.Data getData() throws edu.cmu.sphinx.frontend.DataProcessingException- Specified by:
getDatain interfaceedu.cmu.sphinx.frontend.DataProcessor- Specified by:
getDatain classedu.cmu.sphinx.frontend.BaseDataProcessor- Throws:
edu.cmu.sphinx.frontend.DataProcessingException
-
initialize
public void initialize()Initializes this DataProcessor. This is typically called after the DataProcessor has been configured.- Specified by:
initializein interfaceedu.cmu.sphinx.frontend.DataProcessor- Overrides:
initializein classedu.cmu.sphinx.frontend.BaseDataProcessor
-
valuesToBytes
public static byte[] valuesToBytes(double[] values, int bytesPerValue, boolean signedData) throws ArrayIndexOutOfBoundsException Converts a big-endian byte array into an array of doubles. Each consecutive bytes in the byte array are converted into a double, and becomes the next element in the double array. The size of the returned array is (length/bytesPerValue). Currently, only 1 byte (8-bit) or 2 bytes (16-bit) samples are supported.- Parameters:
values- source valuesbytesPerValue- the number of bytes per valuesignedData- whether the data is signed- Returns:
- a double array, or
nullif byteArray is of zero length - Throws:
ArrayIndexOutOfBoundsException- if boundary fails
-
recordSegment
protected void recordSegment() -
getSegment
public byte[] getSegment(int index) -
getStartTime
public long getStartTime(int index) -
getEndTime
public long getEndTime(int index)
-