framed
Class CMS1

java.lang.Object
  extended by framed.CMS1
All Implemented Interfaces:
FrameSource

public class CMS1
extends java.lang.Object
implements FrameSource

Simple straight-forward (offline) cepstral mean subtraction. Compute the mean large amount of speech data to get a reliable value. A good strategy is also to compute the mean on an utterance or speaker basis.

Author:
sikoried

Constructor Summary
CMS1(FrameSource source, double[] mean)
          Generate a cepstral mean subtraction object using the given source and mean vector; no dynamic update
 
Method Summary
static long computeMeanFromSource(FrameSource source, double[] mean)
          Compute the mean vector from the given frame source.
 int getFrameSize()
          Return the length of the frames (needed for the read call)
static CMS1 loadMeanFromFile(java.lang.String fileName, FrameSource source)
          Load a mean vector from the specified file.
 boolean read(double[] buf)
          Read the next frame, subtract the mean if speech
 void saveMeanToFile(java.lang.String fileName)
          Save the current mean vector to the specified file.
 java.lang.String toString()
          Return a String representation of the object
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CMS1

public CMS1(FrameSource source,
            double[] mean)
Generate a cepstral mean subtraction object using the given source and mean vector; no dynamic update

Parameters:
source - Source to read from
mean - Mean value @see loadMeanFromFile
Method Detail

computeMeanFromSource

public static long computeMeanFromSource(FrameSource source,
                                         double[] mean)
                                  throws java.io.IOException
Compute the mean vector from the given frame source. sikoried: The numeric quality might be low due as there is a full summation with a single division in the end.

Parameters:
source - FrameSource to read from
Returns:
number of samples read
Throws:
java.io.IOException

getFrameSize

public int getFrameSize()
Description copied from interface: FrameSource
Return the length of the frames (needed for the read call)

Specified by:
getFrameSize in interface FrameSource

loadMeanFromFile

public static CMS1 loadMeanFromFile(java.lang.String fileName,
                                    FrameSource source)
                             throws java.io.IOException
Load a mean vector from the specified file.

Parameters:
fileName -
source - connector for the newly created CMS
Returns:
Mean vector
Throws:
java.io.IOException

read

public boolean read(double[] buf)
             throws java.io.IOException
Read the next frame, subtract the mean if speech

Specified by:
read in interface FrameSource
Parameters:
buf - buffer to save the frame; implementing objects may depend on a constant dimensionduring subsequent calls
Returns:
true on success, false if the stream terminated before the window was filled
Throws:
java.io.IOException

saveMeanToFile

public void saveMeanToFile(java.lang.String fileName)
                    throws java.io.IOException
Save the current mean vector to the specified file.

Parameters:
fileName -
Throws:
java.io.IOException

toString

public java.lang.String toString()
Return a String representation of the object

Specified by:
toString in interface FrameSource
Overrides:
toString in class java.lang.Object