inpro.sphinx.instrumentation
Class LabelWriter

java.lang.Object
  extended by inpro.sphinx.instrumentation.LabelWriter
All Implemented Interfaces:
edu.cmu.sphinx.decoder.ResultListener, edu.cmu.sphinx.instrumentation.Monitor, edu.cmu.sphinx.instrumentation.Resetable, edu.cmu.sphinx.recognizer.StateListener, edu.cmu.sphinx.util.props.Configurable, java.util.EventListener
Direct Known Subclasses:
TEDviewNotifier

public class LabelWriter
extends java.lang.Object
implements edu.cmu.sphinx.util.props.Configurable, edu.cmu.sphinx.decoder.ResultListener, edu.cmu.sphinx.instrumentation.Resetable, edu.cmu.sphinx.recognizer.StateListener, edu.cmu.sphinx.instrumentation.Monitor

inspects the current results and writes the phone-alignment to stdout or to a file


Field Summary
private  java.lang.String fileBaseName
           
private  boolean fileOutput
           
protected  boolean finalResult
           
(package private)  int fixedLag
           
protected  boolean intermediateResults
           
private  int nBest
           
protected  boolean phoneAlignment
           
private  java.io.PrintStream phoneAlignmentStream
           
static java.lang.String PROP_FILE_BASE_NAME
           
static java.lang.String PROP_FILE_OUTPUT
           
static java.lang.String PROP_FINAL_RESULT
           
static java.lang.String PROP_FIXED_LAG
           
static java.lang.String PROP_INTERMEDIATE_RESULTS
           
static java.lang.String PROP_N_BEST
           
static java.lang.String PROP_PHONE_ALIGNMENT
           
static java.lang.String PROP_RECOGNIZER
          A Sphinx property that defines which recognizer to monitor
static java.lang.String PROP_STEP_WIDTH
           
static java.lang.String PROP_WORD_ALIGNMENT
           
private  edu.cmu.sphinx.recognizer.Recognizer recognizer
           
protected  int step
          counts the number of recognition steps
protected  int stepWidth
           
protected  boolean wordAlignment
           
private  java.io.PrintStream wordAlignmentStream
           
 
Constructor Summary
LabelWriter()
           
 
Method Summary
private static java.util.List<edu.cmu.sphinx.decoder.search.Token> getAllBestTokens(edu.cmu.sphinx.result.Result result)
          get all tokens on the best path
protected static java.util.List<edu.cmu.sphinx.decoder.search.Token> getBestPhoneTokens(edu.cmu.sphinx.decoder.search.Token token)
          get the phone-tokens on the best path
protected  java.util.List<edu.cmu.sphinx.decoder.search.Token> getBestWordTokens(edu.cmu.sphinx.decoder.search.Token token)
          get the word-tokens on the best path
 void newProperties(edu.cmu.sphinx.util.props.PropertySheet ps)
           
 void newResult(edu.cmu.sphinx.result.Result result)
           
 void reset()
           
private  java.io.PrintStream setStream(java.lang.String extension)
           
 void statusChanged(edu.cmu.sphinx.recognizer.Recognizer.State status)
           
static java.lang.String tokenListToAlignment(java.util.List<edu.cmu.sphinx.decoder.search.Token> list, int lastFrame)
          convert a token list to an alignment string
private  java.lang.String writeAlignment(java.util.List<edu.cmu.sphinx.decoder.search.Token> list, java.io.PrintStream stream, boolean timestamp)
          write labels of aligned segments or words to stream <!
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_RECOGNIZER

@S4Component(type=edu.cmu.sphinx.recognizer.Recognizer.class)
public static final java.lang.String PROP_RECOGNIZER
A Sphinx property that defines which recognizer to monitor

See Also:
Constant Field Values

PROP_INTERMEDIATE_RESULTS

@S4Boolean(defaultValue=false)
public static final java.lang.String PROP_INTERMEDIATE_RESULTS
See Also:
Constant Field Values

PROP_FINAL_RESULT

@S4Boolean(defaultValue=true)
public static final java.lang.String PROP_FINAL_RESULT
See Also:
Constant Field Values

PROP_STEP_WIDTH

@S4Integer(defaultValue=1)
public static final java.lang.String PROP_STEP_WIDTH
See Also:
Constant Field Values

PROP_WORD_ALIGNMENT

@S4Boolean(defaultValue=false)
public static final java.lang.String PROP_WORD_ALIGNMENT
See Also:
Constant Field Values

PROP_PHONE_ALIGNMENT

@S4Boolean(defaultValue=false)
public static final java.lang.String PROP_PHONE_ALIGNMENT
See Also:
Constant Field Values

PROP_FILE_OUTPUT

@S4Boolean(defaultValue=false)
public static final java.lang.String PROP_FILE_OUTPUT
See Also:
Constant Field Values

PROP_FILE_BASE_NAME

@S4String(defaultValue="")
public static final java.lang.String PROP_FILE_BASE_NAME
See Also:
Constant Field Values

PROP_N_BEST

@S4Integer(defaultValue=1)
public static final java.lang.String PROP_N_BEST
See Also:
Constant Field Values

PROP_FIXED_LAG

@S4Integer(defaultValue=0)
public static final java.lang.String PROP_FIXED_LAG
See Also:
Constant Field Values

fixedLag

int fixedLag

recognizer

private edu.cmu.sphinx.recognizer.Recognizer recognizer

intermediateResults

protected boolean intermediateResults

finalResult

protected boolean finalResult

fileOutput

private boolean fileOutput

fileBaseName

private java.lang.String fileBaseName

nBest

private int nBest

wordAlignment

protected boolean wordAlignment

phoneAlignment

protected boolean phoneAlignment

wordAlignmentStream

private java.io.PrintStream wordAlignmentStream

phoneAlignmentStream

private java.io.PrintStream phoneAlignmentStream

step

protected int step
counts the number of recognition steps


stepWidth

protected int stepWidth
Constructor Detail

LabelWriter

public LabelWriter()
Method Detail

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
Throws:
edu.cmu.sphinx.util.props.PropertyException

reset

public void reset()
Specified by:
reset in interface edu.cmu.sphinx.instrumentation.Resetable

setStream

private java.io.PrintStream setStream(java.lang.String extension)

getBestWordTokens

protected java.util.List<edu.cmu.sphinx.decoder.search.Token> getBestWordTokens(edu.cmu.sphinx.decoder.search.Token token)
get the word-tokens on the best path

Parameters:
token - the result to analyse
Returns:
List of word tokens on the best path

getBestPhoneTokens

protected static java.util.List<edu.cmu.sphinx.decoder.search.Token> getBestPhoneTokens(edu.cmu.sphinx.decoder.search.Token token)
get the phone-tokens on the best path

Parameters:
token - the result to analyse
Returns:
List of phone tokens on the best path

getAllBestTokens

private static java.util.List<edu.cmu.sphinx.decoder.search.Token> getAllBestTokens(edu.cmu.sphinx.result.Result result)
get all tokens on the best path

Parameters:
result - the result to analyse
Returns:
List of all tokens on the best path

tokenListToAlignment

public static java.lang.String tokenListToAlignment(java.util.List<edu.cmu.sphinx.decoder.search.Token> list,
                                                    int lastFrame)
convert a token list to an alignment string

Parameters:
list - list of tokens

writeAlignment

private java.lang.String writeAlignment(java.util.List<edu.cmu.sphinx.decoder.search.Token> list,
                                        java.io.PrintStream stream,
                                        boolean timestamp)
write labels of aligned segments or words to stream <!--if it differs from lastAlignment-->

Parameters:
list -
stream -
timestamp -

newResult

public void newResult(edu.cmu.sphinx.result.Result result)
Specified by:
newResult in interface edu.cmu.sphinx.decoder.ResultListener

statusChanged

public void statusChanged(edu.cmu.sphinx.recognizer.Recognizer.State status)
Specified by:
statusChanged in interface edu.cmu.sphinx.recognizer.StateListener