|
|||||||||
| 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
| Nested Class Summary | |
|---|---|
static class |
Recognizer.State
Defines the possible states of the recognizer. |
| 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()
|
|
Recognizer(Decoder decoder,
java.util.List monitors)
|
|
| 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. |
Recognizer.State |
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(Decoder decoder,
java.util.List monitors)
public Recognizer()
| Method Detail |
|---|
public void newProperties(PropertySheet ps)
throws PropertyException
Configurable
newProperties in interface Configurableps - 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 state
public Result recognize()
throws java.lang.IllegalStateException
allocated state.
java.lang.IllegalStateException - if the recognizer is not in the ALLOCATED state
public void allocate()
throws java.lang.IllegalStateException
deallocated state.
java.lang.IllegalStateException - if the recognizer is not in the DEALLOCATED state
public void deallocate()
throws java.lang.IllegalStateException
allocated
state.
java.lang.IllegalStateException - if the recognizer is not in the ALLOCATED statepublic Recognizer.State getState()
public void resetMonitors()
public void addResultListener(ResultListener resultListener)
addResultListener in interface ResultProducerresultListener - the listener to addpublic void addStateListener(StateListener stateListener)
stateListener - the listener to addpublic void removeResultListener(ResultListener resultListener)
removeResultListener in interface ResultProducerresultListener - 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 | ||||||||