speech.think
Interface LoudMouth
- All Superinterfaces:
- Agent, Remote
- All Known Implementing Classes:
- LoudMouthAgent
- public interface LoudMouth
- extends Agent
Allows agents to control the room the same way people do by
talking. I put this into an agent, rather than just having agents
call GrammarCenter.processString() themselves so we can divert or
track this if we ever want to.
The agent has two methods, "thinkOutloud" and "thinkQuietly".
These cause the room to respond to the given text as if it were
spoken outloud. (The Outloud method also causes the room to say
the given text prefaced by "I am thinking.") They return the name
of the rule that parsed the text or null if no rule did.
You can see speech.speechin.LoudMouthTestAgent for an example of
the LoudMouth in use.
Note the following. Suppose your code looks like:
LampManagerSpeech lms = (LampManagerSpeech)
reliesOn("agentland.device.speechin.LampManagerSpeech");
LoudMouth lm = (LoudMouth) reliesOn("speech.LoudMouth");
lm.thinkOutloud("turn on the light by the door");
Nothing will happen! Because the agents are started
asynchronously, the LoudMouth agent will think "turn on the ..."
before the grammars for the LampManagerSpeech have had time to
load. Therefore, you must add explicit synchronization, such as:
LampManagerSpeech lms = (LampManagerSpeech)
reliesOn("agentland.device.speechin.LampManagerSpeech");
lms.alive();
LoudMouth lm = (LoudMouth) reliesOn("speech.LoudMouth");
lm.thinkOutloud("turn on the light by the door");
The alive() call will block until the LampManagerSpeechAgent has
emerged from its constructor, where presumably its grammars are all
loaded.
- See Also:
Agent
thinkOutloud
public String thinkOutloud(String text)
throws RemoteException
- Returns null if no rule parses the string
- Parameters:
text
- a String
value- Returns:
- a
String
value - Throws:
RemoteException
- if an error occurs
thinkOutloud
public String thinkOutloud(String sText,
String sPretext)
throws RemoteException
- Says the text in sPretext, and thinks the text in sText
- Parameters:
sText
- a String
valuesPretext
- a String
value- Returns:
- a
String
value - Throws:
RemoteException
- if an error occurs
thinkQuietly
public String thinkQuietly(String text)
throws RemoteException
- Returns null if no rule parses the string
- Parameters:
text
- a String
value- Returns:
- a
String
value - Throws:
RemoteException
- if an error occurs