speech
Interface GrammarCenter

All Superinterfaces:
Agent, Good, Managed, Remote, Spy
All Known Implementing Classes:
GrammarCenterAgent

public interface GrammarCenter
extends Managed

This is the center where it listens to the user and farms out stuff to various AppGrammars.

See Also:
Managed

Fields inherited from interface metaglue.Agent
ALIVE, DIED, NO_METAGLUE, NOT_RUNNING, STARTING
 
Method Summary
 void activate(String grammarName)
          Activate a grammar, so that any public rule in the grammar can be spoken.
 void activate(String grammarName, String ruleName)
          Activate a specific rule in a grammar so that it can be spoken
 void addAlternative(String grammarName, String ruleName, String spokenText)
          This adds an alternative to some rule.
 void addAlternativeRule(String grammarName, String ruleName, String ruleNameToAdd)
          Add an alternative rule to the given rule.
 void addAlternatives(String grammarName, String ruleName, Collection spokenText)
          This does the same as the single case, but for a vector of alternatives.
 void addDictationListener()
          Registers a listener for dictation events.
 void addNewRuleAlternatives(String grammarName, String ruleName)
          Adds a new rule to the given grammar as a RuleAlternative.
 void deactivate(String grammarName)
          Deactivate all the rules in a grammar
 void deactivate(String grammarName, String ruleName)
          Deactivate a specific rule in a grammar.
 Vector getActiveGrammars()
          Gets all the active grammars.
 Vector getActiveRules(String grammarName)
          Gets all the rules in a grammar that are set active.
 String getDictation()
          Sets the speech system to dictation mode, where it listens for a single sentence of speech from the user.
 String getFile(String grammarName)
          Gets the String name of the file of this grammar.
 String getGrammar(String grammar, AgentID whocares)
          Get a handle into one of the grammers in the center.
 Vector getPublicRules(String grammarName)
          Gets all the rules in the grammar that are marked public.
 String getRandomSentence(String sGrammarName)
          Randomly picks a public rule from a given grammar, and randomly generates a sentence based on that rule.
 String getRandomSentence(String sGrammarName, boolean bPublicRulesOnly)
          If bPublicRulesOnly is true, randomly picks a public rule from a given grammar, and randomly generates a sentence based on that rule.
 String getRandomSentence(String sGrammarName, String sRuleName)
          Gets a random sentence based on a rule in a given grammar.
 boolean hasRule(String grammarName, String ruleName)
          Determines whether the given grammar has the given rule.
 boolean isEnabled(String grammarName)
          Gets whether or not this grammar is enabled.
 Enumeration listRuleNames(String grammarName)
          Lists the names of the rules of a given grammar.
 void pauseRecognizer()
          Pause ViaVoice's recognizer.
 void playWav(String wavFile, boolean sync)
          Speech out playing files.
 void printRules(String grammarName)
          Prints out the rules in a specified grammar to standard output
 String processString(String text)
          Tries to match a String text with one of Listen's RuleGrammars.
 void releaseGrammar(String gname, AgentID whocares)
          Let an owner of a grammar release it.
 void requestWakeUp()
          Requests that the speech system start listening for public rules.
 void requestWakeUp(boolean playattention)
          Requests that the speech system start listening for public rules.
 void resumeRecognizer()
          Resumes ViaVoice's recognizer.
 void save(String grammarName)
          Calls the save method on the underlying ApplicationGrammar
 void say(String text, boolean sync)
          Speech out via local IBM viavoice.
 String sayRandomSentence(String sGrammarName)
          Picks a random public rule from a given grammar, and says a random sentence from that rule.
 void setAlternatives(String grammarName, String ruleName, Collection spokenText)
          Sets the alternatives of a given rule.
 void setDictionFromTypeWriter(boolean b)
           
 void setTypeWriter(String AgentID)
           
 boolean sleeping()
           
 
Methods inherited from interface agentland.resource.Managed
getNeed, replace, replace, resources, yank, yank
 
Methods inherited from interface agentland.util.Good
getHistory, getHistoryElement, resetHistory
 
Methods inherited from interface metaglue.Agent
addMonitor, alive, getAgentID, getMetaglueAgentID, getOldLogs, shutdown, startup, whereAreYou
 
Methods inherited from interface agentland.util.Spy
tell
 

Method Detail

getDictation

public String getDictation()
                    throws RemoteException
Sets the speech system to dictation mode, where it listens for a single sentence of speech from the user. The spoken sentence can contain any word that Viavoice knows about (does not have to be in a RuleGrammar).
Returns:
a String value

requestWakeUp

public void requestWakeUp()
                   throws RemoteException
Requests that the speech system start listening for public rules.

requestWakeUp

public void requestWakeUp(boolean playattention)
                   throws RemoteException
Requests that the speech system start listening for public rules.
Parameters:
playattention - a boolean value

processString

public String processString(String text)
                     throws RemoteException
Tries to match a String text with one of Listen's RuleGrammars. This method essentially "pretends" that the given text was spoken by a person.
Parameters:
text - a String value
Returns:
a String value

setDictionFromTypeWriter

public void setDictionFromTypeWriter(boolean b)
                              throws RemoteException

setTypeWriter

public void setTypeWriter(String AgentID)
                   throws RemoteException

getGrammar

public String getGrammar(String grammar,
                         AgentID whocares)
                  throws RemoteException
Get a handle into one of the grammers in the center. Loads grammar as well, of course.

releaseGrammar

public void releaseGrammar(String gname,
                           AgentID whocares)
                    throws RemoteException
Let an owner of a grammar release it. Grammar will be trashed if no one else owns it.

pauseRecognizer

public void pauseRecognizer()
                     throws RemoteException
Pause ViaVoice's recognizer.

resumeRecognizer

public void resumeRecognizer()
                      throws RemoteException
Resumes ViaVoice's recognizer.

playWav

public void playWav(String wavFile,
                    boolean sync)
             throws RemoteException
Speech out playing files. Use IBM machine, NOT Laureatte.
Parameters:
wavFile - a String value
sync - block until call completed.
Throws:
RemoteException - if an error occurs

say

public void say(String text,
                boolean sync)
         throws RemoteException
Speech out via local IBM viavoice. NOT Laureatte.
Parameters:
text - a String value
sync - a boolean value
Throws:
RemoteException - if an error occurs

listRuleNames

public Enumeration listRuleNames(String grammarName)
                          throws RemoteException
Lists the names of the rules of a given grammar.
Parameters:
grammarName - a String value
Returns:
an Enumeration value

addAlternative

public void addAlternative(String grammarName,
                           String ruleName,
                           String spokenText)
                    throws RemoteException
This adds an alternative to some rule. So if you had a rule mapping to pig | dog, you could add cat so it would map to pig | dog | cat
Parameters:
grammarName - a String value
ruleName - a String value
spokenText - a String value

addAlternatives

public void addAlternatives(String grammarName,
                            String ruleName,
                            Collection spokenText)
                     throws RemoteException
This does the same as the single case, but for a vector of alternatives. More efficient.
Parameters:
grammarName - a String value
ruleName - a String value
spokenText - a Collection value
See Also:
addAlternative(String,String,String)

save

public void save(String grammarName)
          throws RemoteException
Calls the save method on the underlying ApplicationGrammar
Parameters:
grammarName - a String value
See Also:
ApplicationGrammar

activate

public void activate(String grammarName)
              throws RemoteException
Activate a grammar, so that any public rule in the grammar can be spoken.
Parameters:
grammarName - a String value

activate

public void activate(String grammarName,
                     String ruleName)
              throws RemoteException
Activate a specific rule in a grammar so that it can be spoken
Parameters:
grammarName - a String value
ruleName - a String value

deactivate

public void deactivate(String grammarName)
                throws RemoteException
Deactivate all the rules in a grammar
Parameters:
grammarName - a String value

deactivate

public void deactivate(String grammarName,
                       String ruleName)
                throws RemoteException
Deactivate a specific rule in a grammar.
Parameters:
grammarName - a String value
ruleName - a String value

getPublicRules

public Vector getPublicRules(String grammarName)
                      throws RemoteException
Gets all the rules in the grammar that are marked public.
Parameters:
sGrammarName - a String value
Returns:
a Vector value

getActiveRules

public Vector getActiveRules(String grammarName)
                      throws RemoteException
Gets all the rules in a grammar that are set active.
Parameters:
sGrammarName - a String value
Returns:
a Vector value

getActiveGrammars

public Vector getActiveGrammars()
                         throws RemoteException
Gets all the active grammars.
Returns:
a Vector value

getFile

public String getFile(String grammarName)
               throws RemoteException
Gets the String name of the file of this grammar.
Parameters:
grammarName - a String value
Returns:
a String value

isEnabled

public boolean isEnabled(String grammarName)
                  throws RemoteException
Gets whether or not this grammar is enabled.
Parameters:
grammarName - a String value
Returns:
a boolean value

addAlternativeRule

public void addAlternativeRule(String grammarName,
                               String ruleName,
                               String ruleNameToAdd)
                        throws RemoteException
Add an alternative rule to the given rule.
Parameters:
grammarName - a String value
ruleName - a String value
ruleNameToAdd - a String value

setAlternatives

public void setAlternatives(String grammarName,
                            String ruleName,
                            Collection spokenText)
                     throws RemoteException
Sets the alternatives of a given rule.
Parameters:
grammarName - a String value
ruleName - a String value
spokenText - a Collection value

addNewRuleAlternatives

public void addNewRuleAlternatives(String grammarName,
                                   String ruleName)
                            throws RemoteException
Adds a new rule to the given grammar as a RuleAlternative.
Parameters:
grammarName - a String value
ruleName - a String value

hasRule

public boolean hasRule(String grammarName,
                       String ruleName)
                throws RemoteException
Determines whether the given grammar has the given rule.
Parameters:
grammarName - a String value
ruleName - a String value
Returns:
a boolean value

printRules

public void printRules(String grammarName)
                throws RemoteException
Prints out the rules in a specified grammar to standard output
Parameters:
grammarName - the name of the grammar

addDictationListener

public void addDictationListener()
                          throws RemoteException
Registers a listener for dictation events. The listener will send notifications when dictation results are received.
Throws:
RemoteException - if an error occurs

getRandomSentence

public String getRandomSentence(String sGrammarName,
                                String sRuleName)
                         throws RemoteException
Gets a random sentence based on a rule in a given grammar. If the grammar is not already loaded into GrammarCenter, then it will be added as a new ApplicationGrammar
Parameters:
sGrammarName - a String value
sRuleName - a String value
Returns:
a String value

getRandomSentence

public String getRandomSentence(String sGrammarName)
                         throws RemoteException
Randomly picks a public rule from a given grammar, and randomly generates a sentence based on that rule.
Parameters:
sGrammarName - a String value
Returns:
a String value
See Also:
getRandomSentence(String,boolean)

getRandomSentence

public String getRandomSentence(String sGrammarName,
                                boolean bPublicRulesOnly)
                         throws RemoteException
If bPublicRulesOnly is true, randomly picks a public rule from a given grammar, and randomly generates a sentence based on that rule. Otherwise, randomly picks from any rule in a grammar.
Parameters:
sGrammarName - a String value
bPublicRulesOnly - a boolean value
Returns:
a String value

sayRandomSentence

public String sayRandomSentence(String sGrammarName)
                         throws RemoteException
Picks a random public rule from a given grammar, and says a random sentence from that rule.
Parameters:
sGrammarName - a String value
Returns:
a String value
See Also:
getRandomSentence(String)

sleeping

public boolean sleeping()
                 throws RemoteException