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

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
     
    static final String
    The property for the number of bits per value.
    static final String
    The property specifying whether the input data is signed.

    Fields inherited from class edu.cmu.sphinx.util.props.ConfigurableAdapter

    logger
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    SegmentStorer(String dumpFilePath, boolean isCompletePath, int bitsPerSample, boolean isSigned)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    edu.cmu.sphinx.frontend.Data
     
    long
    getEndTime(int index)
     
    byte[]
    getSegment(int index)
     
    long
    getStartTime(int index)
     
    void
    Initializes this DataProcessor.
    void
    newProperties(edu.cmu.sphinx.util.props.PropertySheet ps)
     
    protected void
     
    static 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, 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 Details

    • PROP_BITS_PER_SAMPLE

      @S4Integer(defaultValue=16) public static final String PROP_BITS_PER_SAMPLE
      The property for the number of bits per value.
      See Also:
    • PROP_SIGNED_DATA

      @S4Boolean(defaultValue=true) public static final String 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:
      newProperties in interface edu.cmu.sphinx.util.props.Configurable
      Overrides:
      newProperties in class edu.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:
      getData in interface edu.cmu.sphinx.frontend.DataProcessor
      Specified by:
      getData in class edu.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:
      initialize in interface edu.cmu.sphinx.frontend.DataProcessor
      Overrides:
      initialize in class edu.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 values
      bytesPerValue - the number of bytes per value
      signedData - whether the data is signed
      Returns:
      a double array, or null if 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)