public class FlatLinguist extends java.lang.Object implements Linguist, Configurable
The flat linguist takes a Grammar graph (as returned by the underlying, configurable grammar), and generates a search graph for this grammar.
It makes the following simplifying assumptions:
Modifier and Type | Class and Description |
---|---|
protected class |
FlatLinguist.FlatSearchGraph
The search graph that is produced by the flat linguist.
|
protected class |
FlatLinguist.GState
This is a nested class that is used to manage the construction of the states in a grammar node.
|
Modifier and Type | Field and Description |
---|---|
protected StatisticsVariable |
actualArcs |
protected boolean |
addOutOfGrammarBranch |
protected Cache<SentenceHMMStateArc> |
arcPool |
protected Grammar |
grammar |
protected GrammarNode |
initialGrammarState |
protected LogMath |
logMath |
protected static float |
logOne |
protected float |
logOutOfGrammarBranchProbability |
protected float |
logPhoneInsertionProbability |
protected java.util.Map<GrammarNode,FlatLinguist.GState> |
nodeStateMap |
protected AcousticModel |
phoneLoopAcousticModel |
static java.lang.String |
PROP_ACOUSTIC_MODEL
The property used to define the acoustic model to use when building the search graph
|
static java.lang.String |
PROP_ADD_OUT_OF_GRAMMAR_BRANCH
The property that specifies whether to add a branch for detecting out-of-grammar utterances.
|
static java.lang.String |
PROP_DUMP_GSTATES
The property used to determine whether or not the gstates are dumped.
|
static java.lang.String |
PROP_GRAMMAR
The property used to define the grammar to use when building the search graph
|
static java.lang.String |
PROP_OUT_OF_GRAMMAR_PROBABILITY
The property for the probability of entering the out-of-grammar branch.
|
static java.lang.String |
PROP_PHONE_INSERTION_PROBABILITY
The property for the probability of inserting a CI phone in the out-of-grammar ci phone loop
|
static java.lang.String |
PROP_PHONE_LOOP_ACOUSTIC_MODEL
The property for the acoustic model used for the CI phone loop.
|
static java.lang.String |
PROP_SHOW_COMPILATION_PROGRESS
Property to control whether compilation progress is displayed on standard output.
|
static java.lang.String |
PROP_SPREAD_WORD_PROBABILITIES_ACROSS_PRONUNCIATIONS
Property that controls whether word probabilities are spread across all pronunciations.
|
static java.lang.String |
PROP_UNIT_MANAGER
The property used to define the unit manager to use when building the search graph
|
protected SearchGraph |
searchGraph |
protected StatisticsVariable |
totalArcs |
protected StatisticsVariable |
totalStates |
PROP_FILLER_INSERTION_PROBABILITY, PROP_LANGUAGE_WEIGHT, PROP_SILENCE_INSERTION_PROBABILITY, PROP_UNIT_INSERTION_PROBABILITY, PROP_WORD_INSERTION_PROBABILITY
Constructor and Description |
---|
FlatLinguist() |
FlatLinguist(AcousticModel acousticModel,
Grammar grammar,
UnitManager unitManager,
double wordInsertionProbability,
double silenceInsertionProbability,
double fillerInsertionProbability,
double unitInsertionProbability,
float languageWeight,
boolean dumpGStates,
boolean showCompilationProgress,
boolean spreadWordProbabilitiesAcrossPronunciations,
boolean addOutOfGrammarBranch,
double outOfGrammarBranchProbability,
double phoneInsertionProbability,
AcousticModel phoneLoopAcousticModel) |
Modifier and Type | Method and Description |
---|---|
protected void |
addStartingPath()
Ensures that there is a starting path by adding an empty left context to the starting gstate
|
protected void |
addStartingPath(GrammarNode initialNode)
Start the search at the indicated node
|
void |
allocate()
Allocates the linguist.
|
protected void |
allocateAcousticModel()
Allocates the acoustic model.
|
protected java.util.Collection<SentenceHMMState> |
compileGrammar()
Compiles the grammar into a sentence HMM.
|
protected FlatLinguist.GState |
createGState(GrammarNode grammarNode)
Returns a new GState for the given GrammarNode.
|
void |
deallocate()
Deallocates the linguist.
|
protected SentenceHMMState |
findStartingState()
Finds the starting state
|
protected SentenceHMMStateArc |
getArc(SentenceHMMState nextState,
float logLanguageProbability,
float logInsertionProbability)
Gets a SentenceHMMStateArc.
|
protected FlatLinguist.GState |
getGState(GrammarNode node)
Given a grammar node, retrieve the grammar state
|
float |
getLogSilenceInsertionProbability()
Returns the log silence insertion probability.
|
java.lang.String |
getName() |
SearchGraph |
getSearchGraph()
Returns the search graph
|
protected boolean |
grammarHasChanged()
Determines if the underlying grammar has changed since we last compiled the search graph
|
void |
newProperties(PropertySheet ps)
This method is called when this configurable component needs to be reconfigured.
|
void |
startRecognition()
Called before a recognition
|
void |
stopRecognition()
Called after a recognition
|
@S4Component(type=Grammar.class) public static final java.lang.String PROP_GRAMMAR
@S4Component(type=UnitManager.class) public static final java.lang.String PROP_UNIT_MANAGER
@S4Component(type=AcousticModel.class) public static final java.lang.String PROP_ACOUSTIC_MODEL
@S4Boolean(defaultValue=false) public static final java.lang.String PROP_DUMP_GSTATES
@S4Boolean(defaultValue=false) public static final java.lang.String PROP_ADD_OUT_OF_GRAMMAR_BRANCH
@S4Double(defaultValue=1.0) public static final java.lang.String PROP_OUT_OF_GRAMMAR_PROBABILITY
@S4Component(type=AcousticModel.class) public static final java.lang.String PROP_PHONE_LOOP_ACOUSTIC_MODEL
@S4Double(defaultValue=1.0) public static final java.lang.String PROP_PHONE_INSERTION_PROBABILITY
@S4Boolean(defaultValue=false) public static final java.lang.String PROP_SHOW_COMPILATION_PROGRESS
@S4Boolean(defaultValue=false) public static final java.lang.String PROP_SPREAD_WORD_PROBABILITIES_ACROSS_PRONUNCIATIONS
protected static final float logOne
protected Grammar grammar
protected LogMath logMath
protected AcousticModel phoneLoopAcousticModel
protected boolean addOutOfGrammarBranch
protected float logOutOfGrammarBranchProbability
protected float logPhoneInsertionProbability
protected StatisticsVariable totalStates
protected StatisticsVariable totalArcs
protected StatisticsVariable actualArcs
protected java.util.Map<GrammarNode,FlatLinguist.GState> nodeStateMap
protected Cache<SentenceHMMStateArc> arcPool
protected GrammarNode initialGrammarState
protected SearchGraph searchGraph
public FlatLinguist(AcousticModel acousticModel, Grammar grammar, UnitManager unitManager, double wordInsertionProbability, double silenceInsertionProbability, double fillerInsertionProbability, double unitInsertionProbability, float languageWeight, boolean dumpGStates, boolean showCompilationProgress, boolean spreadWordProbabilitiesAcrossPronunciations, boolean addOutOfGrammarBranch, double outOfGrammarBranchProbability, double phoneInsertionProbability, AcousticModel phoneLoopAcousticModel)
public FlatLinguist()
public SearchGraph getSearchGraph()
getSearchGraph
in interface Linguist
public void newProperties(PropertySheet ps) throws PropertyException
Configurable
newProperties
in interface Configurable
ps
- a property sheet holding the new dataPropertyException
- if there is a problem with the properties.public java.lang.String getName()
public void allocate() throws java.io.IOException
Linguist
Implementor's Note - A well written linguist will allow allocate to be called multiple times without harm. This will allow a linguist to be shared by multiple search managers.
protected void allocateAcousticModel() throws java.io.IOException
java.io.IOException
- if error occuredpublic void deallocate()
Linguist
Implementor's Note - if the linguist is being shared by multiple searches, the deallocate should only actually deallocate things when the last call to deallocate is made. Two approaches for dealing with this:
(1) Keep an allocation counter that is incremented during allocate and decremented during deallocate. Only when the counter reaches zero should the actually deallocation be performed.
(2) Do nothing in dellocate - just the the GC take care of things
deallocate
in interface Linguist
public void startRecognition()
startRecognition
in interface Linguist
public void stopRecognition()
stopRecognition
in interface Linguist
public float getLogSilenceInsertionProbability()
protected java.util.Collection<SentenceHMMState> compileGrammar()
protected FlatLinguist.GState createGState(GrammarNode grammarNode)
grammarNode
- grammar nodeprotected void addStartingPath()
protected void addStartingPath(GrammarNode initialNode)
initialNode
- initial nodeprotected boolean grammarHasChanged()
protected SentenceHMMState findStartingState()
protected SentenceHMMStateArc getArc(SentenceHMMState nextState, float logLanguageProbability, float logInsertionProbability)
nextState
- the next statelogLanguageProbability
- the log language probabilitylogInsertionProbability
- the log insertion probabilityprotected FlatLinguist.GState getGState(GrammarNode node)
node
- the grammar node