edu.cmu.sphinx.frontend.util
Class ConcatFileDataSource

java.lang.Object
  extended byedu.cmu.sphinx.frontend.BaseDataProcessor
      extended byedu.cmu.sphinx.frontend.util.StreamDataSource
          extended byedu.cmu.sphinx.frontend.util.ConcatFileDataSource
All Implemented Interfaces:
Configurable, DataProcessor, ReferenceSource

public class ConcatFileDataSource
extends StreamDataSource
implements ReferenceSource

Concatenates a list of audio files as one continuous audio stream. A DataStartSignal will be placed before the start of the first file, and a DataEndSignal after the last file. No DataStartSignal or DataEndSignal will be placed between them. Optionally, silence can be added in-between the audio files by setting the property:

edu.cmu.sphinx.frontend.util.ConcatFileDataSource.silenceFile
to a audio file for silence. By default, no silence is added. Moreover, one can also specify how many files to skip for every file read.

You can also specify the name of a transcript file to write the transcription to. The transcription will be written in HUB-4 style. A sample HUB-4 transcript looks like:

 bn99en_1 1 peter_jennings 0.806084 7.079850  Tonight this 
 Thursday big pressure on the Clinton administration to do something about 
 the latest killing in Yugoslavia
 bn99en_1 1 peter_jennings 7.079850 14.007608  Airline passengers
 and outrageous behavior at thirty thousand feet What can an airline do 
 ...
 bn99en_1 1 inter_segment_gap 23.097000 28.647000 
 ...
 
The format of each line is:
 test_set_name category speaker_name start_time_in_seconds
 end_time_in_seconds  transcript
 
In our example above,
 test_set_name is "bn99en_1"
 category is "1"
 speaker_name is "peter_jennings"
 start_time_in_seconds is "0.806084"
 end_time_in_seconds is "7.079850"
 category is "o" for "Overall"
 hub4_focus_conditions is:
     "f0" for "Baseline//Broadcast//Speech"
     "f1" for "Spontaneous//Broadcast//Speech"
     "f2" for "Speech Over//Telephone//Channels"
     "f3" for "Speech in the//Presence of//Background Music"
     "f4" for "Speech Under//Degraded//Acoustic Conditions"
     "f5" for "Speech from//Non-Native//Speakers"
     "fx" for "All other speech"
 speaker_sex is "male"
 transcript is "Tonight this Thursday big pressure on the Clinton 
 administration to do something about the latest killing in Yugoslavia
 
The ConcatFileDataSource will produce such a transcript if the name of the file to write to is supplied in the constructor. This transcript file will be used in detected gap insertion errors, because it accurately describes the "correct" sequence of speech and silences in the concatenated version of the audio files.


Field Summary
static java.lang.String PROP_ADD_RANDOM_SILENCE
          The SphinxProperty that specifies whether to add random silence.
static boolean PROP_ADD_RANDOM_SILENCE_DEFAULT
          The default value for PROP_ADD_RANDOM_SILENCE.
static java.lang.String PROP_BATCH_FILE
          SphinxProperty for the file containing a list of audio files to read from.
static java.lang.String PROP_BATCH_FILE_DEFAULT
          The default value of PROP_BATCH_FILE.
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_MAX_SILENCE
          The SphinxProperty that specifies the maximum number of times the silence file is added between files.
static int PROP_MAX_SILENCE_DEFAULT
          The default value of PROP_MAX_SILENCE.
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_SILENCE_FILE
          The SphinxProperty that specifies the silence audio file, if any.
static java.lang.String PROP_SILENCE_FILE_DEFAULT
          The default value for PROP_SILENCE_FILE.
static java.lang.String PROP_SKIP
          The SphinxProperty that specifies the number of files to skip for every file read.
static int PROP_SKIP_DEFAULT
          The default value for PROP_SKIP.
static java.lang.String PROP_START_FILE
          The SphinxProperty that specifies which file to start at.
static int PROP_START_FILE_DEFAULT
          The default value for PROP_START_FILE_DEFAULT.
static java.lang.String PROP_TOTAL_FILES
          The SphinxProperty that specifies the total number of files to read.
static int PROP_TOTAL_FILES_DEFAULT
          The default value for PROP_TOTAL_FILES.
static java.lang.String PROP_TRANSCRIPT_FILE
          The SphinxProperty that specifies the name of the transcript file.
static java.lang.String PROP_TRANSCRIPT_FILE_DEFAULT
          The default value of PROP_TRANSCRIPT_FILE.
 
Fields inherited from class edu.cmu.sphinx.frontend.util.StreamDataSource
PROP_BIG_ENDIAN_DATA, PROP_BIG_ENDIAN_DATA_DEFAULT, PROP_BYTES_PER_READ, PROP_BYTES_PER_READ_DEFAULT, PROP_SIGNED_DATA, PROP_SIGNED_DATA_DEFAULT
 
Constructor Summary
ConcatFileDataSource()
           
 
Method Summary
 java.util.List getReferences()
          Returns a list of all reference text.
 java.lang.String getTranscriptFile()
          Returns the name of the transcript file.
 void initialize()
          Initializes a ConcatFileDataSource.
 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.
 
Methods inherited from class edu.cmu.sphinx.frontend.util.StreamDataSource
getData, setInputStream
 
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_START_FILE

public static final java.lang.String PROP_START_FILE
The SphinxProperty that specifies which file to start at.

See Also:
Constant Field Values

PROP_START_FILE_DEFAULT

public static final int PROP_START_FILE_DEFAULT
The default value for PROP_START_FILE_DEFAULT.

See Also:
Constant Field Values

PROP_SKIP

public static final java.lang.String PROP_SKIP
The SphinxProperty that specifies the number of files to skip for every file read.

See Also:
Constant Field Values

PROP_SKIP_DEFAULT

public static final int PROP_SKIP_DEFAULT
The default value for PROP_SKIP.

See Also:
Constant Field Values

PROP_TOTAL_FILES

public static final java.lang.String PROP_TOTAL_FILES
The SphinxProperty that specifies the total number of files to read. The default value should be no limit.

See Also:
Constant Field Values

PROP_TOTAL_FILES_DEFAULT

public static final int PROP_TOTAL_FILES_DEFAULT
The default value for PROP_TOTAL_FILES.

See Also:
Constant Field Values

PROP_SILENCE_FILE

public static final java.lang.String PROP_SILENCE_FILE
The SphinxProperty that specifies the silence audio file, if any. If this property is null, then no silences are added in between files.

See Also:
Constant Field Values

PROP_SILENCE_FILE_DEFAULT

public static final java.lang.String PROP_SILENCE_FILE_DEFAULT
The default value for PROP_SILENCE_FILE.


PROP_ADD_RANDOM_SILENCE

public static final java.lang.String PROP_ADD_RANDOM_SILENCE
The SphinxProperty that specifies whether to add random silence.

See Also:
Constant Field Values

PROP_ADD_RANDOM_SILENCE_DEFAULT

public static final boolean PROP_ADD_RANDOM_SILENCE_DEFAULT
The default value for PROP_ADD_RANDOM_SILENCE.

See Also:
Constant Field Values

PROP_MAX_SILENCE

public static final java.lang.String PROP_MAX_SILENCE
The SphinxProperty that specifies the maximum number of times the silence file is added between files. If PROP_ADD_RANDOM_SILENCE is set to true, the number of times the silence file is added is between 1 and this value. If PROP_ADD_RANDOM_SILENCE is set to false, this value will be the number of times the silence file is added. So if PROP_MAX_SILENCE is set to 3, then the silence file will be added three times between files.

See Also:
Constant Field Values

PROP_MAX_SILENCE_DEFAULT

public static final int PROP_MAX_SILENCE_DEFAULT
The default value of PROP_MAX_SILENCE.

See Also:
Constant Field Values

PROP_TRANSCRIPT_FILE

public static final java.lang.String PROP_TRANSCRIPT_FILE
The SphinxProperty that specifies the name of the transcript file. If this property is set, a transcript file will be created. No transcript file will be created if this property is not set.

See Also:
Constant Field Values

PROP_TRANSCRIPT_FILE_DEFAULT

public static final java.lang.String PROP_TRANSCRIPT_FILE_DEFAULT
The default value of PROP_TRANSCRIPT_FILE.


PROP_BATCH_FILE

public static final java.lang.String PROP_BATCH_FILE
SphinxProperty for the file containing a list of audio files to read from.

See Also:
Constant Field Values

PROP_BATCH_FILE_DEFAULT

public static final java.lang.String PROP_BATCH_FILE_DEFAULT
The default value of PROP_BATCH_FILE.


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
Constructor Detail

ConcatFileDataSource

public ConcatFileDataSource()
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 StreamDataSource
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 StreamDataSource
Throws:
PropertyException

initialize

public void initialize()
Initializes a ConcatFileDataSource.

Specified by:
initialize in interface DataProcessor
Overrides:
initialize in class StreamDataSource

getReferences

public java.util.List getReferences()
Returns a list of all reference text. Implements the getReferences() method of ReferenceSource.

Specified by:
getReferences in interface ReferenceSource
Returns:
a list of all reference text

getTranscriptFile

public java.lang.String getTranscriptFile()
Returns the name of the transcript file.

Returns:
the name of the transcript file