|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.cmu.sphinx.recognizer.Recognizer
public class Recognizer
The Sphinx-4 recognizer. This is the main entry point for Sphinx-4. Typical usage of a recognizer is like so:
public void recognizeDigits() {
URL digitsConfig = new URL("file:./digits.xml");
ConfigurationManager cm = new ConfigurationManager(digitsConfig);
Recognizer sphinxDigitsRecognizer
= (Recognizer) cm.lookup("digitsRecognizer"");
boolean done = false;
Result result;
sphinxDigitsRecognizer.allocate();
// echo spoken digits, quit when 'nine' is spoken
while (!done) {
result = sphinxDigitsRecognizer.recognize();
System.out.println("Result: " + result);
done = result.toString().equals("nine");
}
sphinxDigitsRecognizer.deallocate();
}
Note that some Recognizer methods may throw an IllegalStateException if the recognizer is not in the proper state
Field Summary | |
---|---|
static java.lang.String |
PROP_DECODER
Property name for the decoder to be used by this recognizer. |
static java.lang.String |
PROP_MONITORS
Property name for the set of monitors for this recognizer |
Constructor Summary | |
---|---|
Recognizer()
|
Method Summary | |
---|---|
void |
addResultListener(ResultListener resultListener)
Adds a result listener to this recognizer. |
void |
addStateListener(StateListener stateListener)
Adds a status listener to this recognizer. |
void |
allocate()
Allocate the resources needed for the recognizer. |
void |
deallocate()
Deallocates the recognizer. |
RecognizerState |
getState()
Retrieves the recognizer state. |
void |
newProperties(PropertySheet ps)
This method is called when this configurable component needs to be reconfigured. |
Result |
recognize()
Performs recognition for the given number of input frames, or until a 'final' result is generated. |
Result |
recognize(java.lang.String referenceText)
Performs recognition for the given number of input frames, or until a 'final' result is generated. |
void |
removeResultListener(ResultListener resultListener)
Removes a previously added result listener. |
void |
removeStateListener(StateListener stateListener)
Removes a previously added state listener. |
void |
resetMonitors()
Resets the monitors monitoring this recognizer |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
@S4Component(type=Decoder.class) public static final java.lang.String PROP_DECODER
@S4ComponentList(type=StateListener.class) public static final java.lang.String PROP_MONITORS
Constructor Detail |
---|
public Recognizer()
Method Detail |
---|
public void newProperties(PropertySheet ps) throws PropertyException
Configurable
newProperties
in interface Configurable
ps
- a property sheet holding the new data
PropertyException
- if there is a problem with the properties.public Result recognize(java.lang.String referenceText) throws java.lang.IllegalStateException
allocated
state.
referenceText
- what was actually spoken
java.lang.IllegalStateException
- if the recognizer is not in the ALLOCATED
statepublic Result recognize() throws java.lang.IllegalStateException
allocated
state.
java.lang.IllegalStateException
- if the recognizer is not in the ALLOCATED
statepublic void allocate() throws java.lang.IllegalStateException
deallocated
state.
java.lang.IllegalStateException
- if the recognizer is not in the DEALLOCATED
statepublic void deallocate() throws java.lang.IllegalStateException
allocated
state.
java.lang.IllegalStateException
- if the recognizer is not in the ALLOCATED
statepublic RecognizerState getState()
public void resetMonitors()
public void addResultListener(ResultListener resultListener)
addResultListener
in interface ResultProducer
resultListener
- the listener to addpublic void addStateListener(StateListener stateListener)
stateListener
- the listener to addpublic void removeResultListener(ResultListener resultListener)
removeResultListener
in interface ResultProducer
resultListener
- the listener to removepublic void removeStateListener(StateListener stateListener)
stateListener
- the state listener to removepublic java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |