|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--speech.ApplicationGrammar
This is a simplified interface to the rule and dictation grammars in the Java Speech API (JSAPI beta v0.7). This interface provides all the basic functionality of the JSAPI RuleGrammar class but omits for the time being anything esoteric. It also adds several very useful things, such as a save() method, TagsListeners and synchronous getDictation() and saySync() methods. It is also thread-safe. For more information on the Java Speech Grammar Format (JSGF) specification, in which you actually write your grammars, see: http://java.sun.com/products/java-media/speech/forDevelopers/JSGF If you want to use speech recognition from Metaglue, don't use this class directly. Use the AppGrammarAgent instead, which is an agentified interface to this class. Notes: In the ApplicationGrammar model, every grammar has its own thread, so that it can't monopolize control over the recognizer's (& AWT's) event thread. People using this class don't need to be concerned with this, except to note that until you are done processing a given result in your grammar, you can't receive new ones. But, the all-important point is that other ApplicationGrammars can receive their speech events while you are still processing yours. Simply put, don't worry, everything will work the way you (should) expect it to! Sample calls: ApplicationGrammar g = new ApplicationGrammar ("package.grammarName"); g.setEnabled(boolean value); g.addResultListener(Listener myListener); g.addTagsListener(TagsListener myTagsListener); g.removeGrammarListener(Listener myListener); g.activate(); g.deactive(); g.activate(String ruleName); g.deactive(String ruleName); g.addAlternative(String ruleName, String spokenText); g.save(); String spokenText = g.getDictation(); // The following should not be used if you want to be RMI-friendly // (see note below) g.addTagsListener(String tag, TagsListener myTagsListener);
Constructor Summary | |
ApplicationGrammar(String packageList)
Create an ApplicationGrammar, e.g. |
Method Summary | |
void |
activate()
|
void |
activate(String ruleName)
|
void |
addAlternative(String ruleName,
String spokenText)
This adds an alternative to some rule. |
void |
addAlternativeRule(String ruleName,
String ruleNameToAdd)
Adds the rule rulenameToAdd as an alternative in rule ruleName |
void |
addAlternatives(String ruleName,
Vector spokenText)
This does the same as the single case, but for a vector of alternatives. |
void |
addNewRuleAlternatives(String ruleName)
Creates a public RuleAlternatives type rule called ruleName |
void |
addTagsListener(String tag,
TagsListener suppliedListener)
This is not useful if you want to access this via RMI (which is how Metaglue does it), because there's no easy way to do a generalized callback like this. |
void |
addTagsListener(TagsListener suppliedListener)
|
void |
deactivate()
|
void |
deactivate(String ruleName)
|
Vector |
getActiveRules()
|
String |
getFile()
|
String |
getName()
|
Vector |
getPublicRules()
|
boolean |
hasRule(String ruleName)
Returns true if the grammar contains a rule called ruleName |
boolean |
isBad()
Get the value of bad (i.e. |
boolean |
isEnabled()
|
Enumeration |
listRuleNames()
|
void |
manualTrigger(javax.speech.recognition.RuleParse rp,
String text)
|
void |
pauseRecognizer()
|
void |
printRules()
|
String |
processString(String s)
|
void |
removeTagsListener(String tag,
TagsListener suppliedListener)
|
void |
removeTagsListener(TagsListener suppliedListener)
|
void |
requestWakeUp()
|
void |
requestWakeUp(boolean playattention)
|
void |
resumeRecognizer()
|
void |
save()
|
void |
setAlternatives(String ruleName,
Vector spokenText)
Sets the alternatives for ruleName. |
String |
toString()
|
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public ApplicationGrammar(String packageList)
Method Detail |
public boolean isBad()
public Enumeration listRuleNames()
public void printRules()
public void addAlternative(String ruleName, String spokenText)
public void addAlternatives(String ruleName, Vector spokenText)
public void pauseRecognizer()
public void resumeRecognizer()
public void save()
public String toString()
public void addTagsListener(TagsListener suppliedListener)
public void addTagsListener(String tag, TagsListener suppliedListener)
public void removeTagsListener(String tag, TagsListener suppliedListener)
public void removeTagsListener(TagsListener suppliedListener)
public void activate()
public void activate(String ruleName)
public void deactivate()
public void deactivate(String ruleName)
public Vector getPublicRules()
public Vector getActiveRules()
public String getName()
public String getFile()
public void requestWakeUp()
public void requestWakeUp(boolean playattention)
public String processString(String s)
public void manualTrigger(javax.speech.recognition.RuleParse rp, String text)
public boolean isEnabled()
public void addAlternativeRule(String ruleName, String ruleNameToAdd)
public void setAlternatives(String ruleName, Vector spokenText)
public void addNewRuleAlternatives(String ruleName)
public boolean hasRule(String ruleName)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |