speech
Class Listen

java.lang.Object
  |
  +--speech.Listen

public class Listen
extends Object

The startup interaction between viaVoice's speech recognition and synthesis is buggy. Don't change things involving these below in the class's constructor.


Field Summary
static int ASLEEP
           
static int AWAKE
           
static int SLEEP
           
 
Method Summary
 void activate(javax.speech.recognition.RuleGrammar g)
          These are the methods for activating and deactivating individual grammars and their rules.
 void activate(javax.speech.recognition.RuleGrammar g, String ruleName)
           
 void addDictationListener(javax.speech.recognition.ResultListener rListener)
          Registers listener as a listener for dictation events.
 javax.speech.recognition.RuleGrammar addGrammar(String filename)
          Try to avoid using this filename mechanism to load grammars because gramars loaded this way don't really support the JSGF import mechanism.
 javax.speech.recognition.RuleGrammar addGrammar(URL base, String grammarName)
          Load up and add a grammar to the pool of grammars.
 void addSpeechStateListener(SpeechStateListener sListener)
           
 void commitChanges()
          When done mucking about, commit changes.
 void deactivate(javax.speech.recognition.RuleGrammar g)
           
 void deactivate(javax.speech.recognition.RuleGrammar g, String ruleName)
           
 Vector getActiveGrammarNames()
           
 Vector getActiveRules(javax.speech.recognition.RuleGrammar ruleG)
           
 boolean getDaydreamMode()
          Gets whether or not we are daydreaming.
 String getDictation()
          Get a dictation string out of us.
 boolean getDictationMode()
          Indicates whether Listen is always listening to dictation.
static Listen getListen()
          Call this to get the single static object that everything shares.
static Listen getListen(TalkNSing talker)
          Call this to get the single static object that everything shares.
 Vector getPublicRules(javax.speech.recognition.RuleGrammar ruleG)
           
 AckSounds getTalker()
           
static boolean isListen()
          True if Listen has been initialized.
 javax.speech.recognition.RuleGrammar loadJSGF(URL base, String grammarName)
           
static void main(String[] args)
           
 void pauseRecognizer()
           
 String processString(String sText)
          Process a text string against all active grammars
 String processString(String sText, boolean bPlayAcknowledgement)
          Process a text string against all active grammars
 void removeDictationListener(javax.speech.recognition.ResultListener rListener)
          Unregisters listener as a listener for dictation events.
 void requestGoToSleep()
          This is the public version of goToSleep.
 void requestWakeUp()
           
 void requestWakeUp(boolean playattention)
          Public wakeUp method to programatically wake up the system.
 void resumeRecognizer()
           
 void setDaydreamMode(boolean b)
          Sets the speech system into daydream mode.
 void setDictationMode(boolean alwaysDictate)
          Use this to indicate whether dictation should always be on.
 void setTalker(Say talker)
           
 void setTalker(TalkNSing talker)
          Set what plays our noises and says our sayings.,
static Listen setupLinked()
          Make listen use local speech out resources to talk back.
 boolean sleeping()
          Are we in our sleeping state?
 int sleepingState()
           
 void startChanges()
          When starting a series of changes, call this to make sure recognizer is suspended.
 void stayAwake()
          Make sure the system doesn't go to sleep until further notice.
 void updateGCListenerState()
           
 void updateGCListenerVolume(float fVolume)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SLEEP

public static final int SLEEP

ASLEEP

public static final int ASLEEP

AWAKE

public static final int AWAKE
Method Detail

isListen

public static boolean isListen()
True if Listen has been initialized.

getListen

public static Listen getListen(TalkNSing talker)
Call this to get the single static object that everything shares.

getListen

public static Listen getListen()
Call this to get the single static object that everything shares.

setupLinked

public static Listen setupLinked()
Make listen use local speech out resources to talk back.

setTalker

public void setTalker(Say talker)

getTalker

public AckSounds getTalker()

setTalker

public void setTalker(TalkNSing talker)
Set what plays our noises and says our sayings.,

pauseRecognizer

public void pauseRecognizer()

resumeRecognizer

public void resumeRecognizer()

getPublicRules

public Vector getPublicRules(javax.speech.recognition.RuleGrammar ruleG)

getActiveRules

public Vector getActiveRules(javax.speech.recognition.RuleGrammar ruleG)

requestGoToSleep

public void requestGoToSleep()
This is the public version of goToSleep. If the user has told the system to stay awake, then this is ignored.

requestWakeUp

public void requestWakeUp(boolean playattention)
Public wakeUp method to programatically wake up the system.

requestWakeUp

public void requestWakeUp()

stayAwake

public void stayAwake()
Make sure the system doesn't go to sleep until further notice.

sleepingState

public int sleepingState()

sleeping

public boolean sleeping()
Are we in our sleeping state?

activate

public void activate(javax.speech.recognition.RuleGrammar g)
These are the methods for activating and deactivating individual grammars and their rules. I put all of the functionality here rather than in ApplicationGrammar, but perhaps it belongs there instead. Active grammars are ones the room is listening for when it is awake. (E.g., the user has just said, "Computer.") If the room is awake, they are immediately activated. Otherwise, they will become available the next time the room wakes up.

activate

public void activate(javax.speech.recognition.RuleGrammar g,
                     String ruleName)

deactivate

public void deactivate(javax.speech.recognition.RuleGrammar g)

deactivate

public void deactivate(javax.speech.recognition.RuleGrammar g,
                       String ruleName)

addGrammar

public javax.speech.recognition.RuleGrammar addGrammar(URL base,
                                                       String grammarName)
Load up and add a grammar to the pool of grammars.
Returns:
the loaded grammar

loadJSGF

public javax.speech.recognition.RuleGrammar loadJSGF(URL base,
                                                     String grammarName)
                                              throws IOException,
                                                     javax.speech.recognition.GrammarException,
                                                     MalformedURLException

addGrammar

public javax.speech.recognition.RuleGrammar addGrammar(String filename)
Try to avoid using this filename mechanism to load grammars because gramars loaded this way don't really support the JSGF import mechanism.
Parameters:
filename - a String value
Returns:
a RuleGrammar value

processString

public String processString(String sText)
Process a text string against all active grammars
Parameters:
text - a String value
Returns:
a String value

processString

public String processString(String sText,
                            boolean bPlayAcknowledgement)
Process a text string against all active grammars
Parameters:
sText - a String value
bPlayAcknowledgement - a boolean value
Returns:
a String value

startChanges

public void startChanges()
When starting a series of changes, call this to make sure recognizer is suspended.

commitChanges

public void commitChanges()
When done mucking about, commit changes.

getDictation

public String getDictation()
Get a dictation string out of us.

getActiveGrammarNames

public Vector getActiveGrammarNames()

main

public static void main(String[] args)

setDictationMode

public void setDictationMode(boolean alwaysDictate)
Use this to indicate whether dictation should always be on. If dictation is always enabled, then dictation results are received for everything except when the utterance matches a rule grammar. In either mode, getDictation() can still be used.
Parameters:
alwaysDictate - if true, always listen to dictation in addition to rule grammars.

getDictationMode

public boolean getDictationMode()
Indicates whether Listen is always listening to dictation.
Returns:
if true, always listens to dictation.

addDictationListener

public void addDictationListener(javax.speech.recognition.ResultListener rListener)
Registers listener as a listener for dictation events.
Parameters:
listener - a ResultListener

removeDictationListener

public void removeDictationListener(javax.speech.recognition.ResultListener rListener)
Unregisters listener as a listener for dictation events.
Parameters:
rListener - a ResultListener value

setDaydreamMode

public void setDaydreamMode(boolean b)
Sets the speech system into daydream mode. In this mode, the user can say "computer " without the usual pause after the "computer" This is a temporary (but working) hack. I plan to modify the rule grammars to dynamically add the token "computer" before every rule.
Parameters:
b - a boolean value

getDaydreamMode

public boolean getDaydreamMode()
Gets whether or not we are daydreaming.
Returns:
a boolean value
See Also:
setDaydreamMode(boolean)

addSpeechStateListener

public void addSpeechStateListener(SpeechStateListener sListener)

updateGCListenerState

public void updateGCListenerState()

updateGCListenerVolume

public void updateGCListenerVolume(float fVolume)