|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectedu.cmu.sphinx.util.props.ConfigurableAdapter
edu.cmu.sphinx.frontend.BaseDataProcessor
edu.cmu.sphinx.frontend.util.WavWriter
public class WavWriter
Stores audio data into numbered (MS-)wav files. TODO: currently the WavWriter is only able to write data in bigEndian, support for littleEndian would be nice TODO: currently the WavWriter buffers all audio data until a DataEndSignal occurs.
| Field Summary | |
|---|---|
private java.io.ByteArrayOutputStream |
baos
|
private int |
bitsPerSample
Default value for PROP_BITS_PER_SAMPLE. |
protected boolean |
captureUtts
The default value of PROP_SIGNED_DATA. |
private java.io.DataOutputStream |
dos
|
private java.lang.String |
dumpFilePath
The default value for PROP_RAND_STREAM_START |
private boolean |
isCompletePath
|
private boolean |
isInSpeech
|
private boolean |
isSigned
The default value of PROP_SIGNED_DATA. |
static java.lang.String |
PROP_BITS_PER_SAMPLE
The property for the number of bits per value. |
static java.lang.String |
PROP_CAPTURE_UTTERANCES
The property specifying whether the input data is signed. |
static java.lang.String |
PROP_IS_COMPLETE_PATH
|
static java.lang.String |
PROP_OUT_FILE_NAME_PATTERN
The pathname which must obey the pattern: pattern + i + .wav. |
static java.lang.String |
PROP_SIGNED_DATA
The property specifying whether the input data is signed. |
private int |
sampleRate
|
| Fields inherited from class edu.cmu.sphinx.util.props.ConfigurableAdapter |
|---|
logger |
| Constructor Summary | |
|---|---|
WavWriter()
|
|
WavWriter(java.lang.String dumpFilePath,
boolean isCompletePath,
int bitsPerSample,
boolean isSigned,
boolean captureUtts)
|
|
| Method Summary | |
|---|---|
static javax.sound.sampled.AudioInputStream |
convertDoublesToAudioStream(double[] values,
int sampleRate)
|
Data |
getData()
Returns the processed Data output. |
private static int |
getNextFreeIndex(java.lang.String outPattern)
|
private static javax.sound.sampled.AudioFileFormat.Type |
getTargetType(java.lang.String extension)
|
void |
initialize()
Initializes this DataProcessor. |
void |
newProperties(PropertySheet ps)
This method is called when this configurable component needs to be reconfigured. |
static byte[] |
valuesToBytes(double[] values,
int bytesPerValue,
boolean signedData)
Converts a big-endian byte array into an array of doubles. |
protected void |
writeFile(java.lang.String wavName)
Writes the current stream to disc; override this method if you want to take additional action on file writes |
static void |
writeWavFile(double[] signal,
int sampleRate,
java.io.File targetFile)
Writes a given double array into a wav file (given the sample rate of the signal). |
| Methods inherited from class edu.cmu.sphinx.frontend.BaseDataProcessor |
|---|
getPredecessor, getTimer, setPredecessor |
| Methods inherited from class edu.cmu.sphinx.util.props.ConfigurableAdapter |
|---|
getName, initLogger, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
@S4String public static final java.lang.String PROP_OUT_FILE_NAME_PATTERN
@S4Boolean(defaultValue=false) public static final java.lang.String PROP_IS_COMPLETE_PATH
private boolean isCompletePath
private java.lang.String dumpFilePath
@S4Integer(defaultValue=16) public static final java.lang.String PROP_BITS_PER_SAMPLE
private int bitsPerSample
@S4Boolean(defaultValue=true) public static final java.lang.String PROP_SIGNED_DATA
private boolean isSigned
@S4Boolean(defaultValue=false) public static final java.lang.String PROP_CAPTURE_UTTERANCES
protected boolean captureUtts
private java.io.ByteArrayOutputStream baos
private java.io.DataOutputStream dos
private int sampleRate
private boolean isInSpeech
| Constructor Detail |
|---|
public WavWriter(java.lang.String dumpFilePath,
boolean isCompletePath,
int bitsPerSample,
boolean isSigned,
boolean captureUtts)
public WavWriter()
| Method Detail |
|---|
public void newProperties(PropertySheet ps)
throws PropertyException
Configurable
newProperties in interface ConfigurablenewProperties in class ConfigurableAdapterps - a property sheet holding the new data
PropertyException - if there is a problem with the properties.
public Data getData()
throws DataProcessingException
BaseDataProcessor
getData in interface DataProcessorgetData in class BaseDataProcessorDataProcessingException - if a data processor error occursprivate static int getNextFreeIndex(java.lang.String outPattern)
public void initialize()
initialize in interface DataProcessorinitialize in class BaseDataProcessorprivate static javax.sound.sampled.AudioFileFormat.Type getTargetType(java.lang.String extension)
public static byte[] valuesToBytes(double[] values,
int bytesPerValue,
boolean signedData)
throws java.lang.ArrayIndexOutOfBoundsException
values - bytesPerValue - the number of bytes per valuesignedData - whether the data is signed
null if byteArray is of zero length
java.lang.ArrayIndexOutOfBoundsException
public static javax.sound.sampled.AudioInputStream convertDoublesToAudioStream(double[] values,
int sampleRate)
public static void writeWavFile(double[] signal,
int sampleRate,
java.io.File targetFile)
signal - sampleRate - targetFile - protected void writeFile(java.lang.String wavName)
wavName - name of the file to be written
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||