devs.speechpackage
Class SpeechRecognizer

java.lang.Object
  extended by java.lang.Thread
      extended by biocell.BioThread
          extended by nns.BioSensor
              extended by devs.speechpackage.SpeechRecognizer
All Implemented Interfaces:
BioDevice, java.lang.Runnable, java.util.EventListener, MNSListener

public class SpeechRecognizer
extends BioSensor

A demonstration of how to use JSGF grammars in sphinx-4. This program demonstrates how an application can cycle through a number of JSGF grammars as well as how an application can build up grammar rules directly


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class nns.BioSensor
EXTERO_SENSOR, INTERO_SENSOR, PROPRIO_SENSOR
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Fields inherited from interface biocell.BioDevice
BLOCKED, BUSY, CYCLING, DONE, END, PAUSED, RESUMED, START, WAIT
 
Constructor Summary
SpeechRecognizer(BioSensorListener listener)
           
 
Method Summary
 void addListener(BioDeviceListener rP)
           
 void execute()
          Executes the demo.
 int getCurrentPosition()
           
 int getCurrentState()
           
 void initAll()
          Creates a new JSGFDemo.
 void load(MNSEvent cnE)
          simple interface to control all Devices
 void loadCNTR(MNSEvent cnE)
           
 void process(MNSEvent cnv)
          loads a CNSEvent into a listener
 void run()
           
 
Methods inherited from class nns.BioSensor
addListener, addSensorListener, geState, getControls, getListener, getname, getType, seState, setListener, setname, setType
 
Methods inherited from class biocell.BioThread
getCurrentmood, getMoodParam, getstate, setMood, stepEnergy
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SpeechRecognizer

public SpeechRecognizer(BioSensorListener listener)
Method Detail

addListener

public void addListener(BioDeviceListener rP)
Specified by:
addListener in interface BioDevice
Overrides:
addListener in class BioSensor

getCurrentPosition

public int getCurrentPosition()
Specified by:
getCurrentPosition in interface BioDevice
Overrides:
getCurrentPosition in class BioSensor
Returns:

getCurrentState

public int getCurrentState()
Specified by:
getCurrentState in interface BioDevice
Overrides:
getCurrentState in class BioSensor
Returns:

load

public void load(MNSEvent cnE)
Description copied from interface: BioDevice
simple interface to control all Devices

Specified by:
load in interface BioDevice
Overrides:
load in class BioSensor

loadCNTR

public void loadCNTR(MNSEvent cnE)
Specified by:
loadCNTR in interface BioDevice
Overrides:
loadCNTR in class BioSensor

process

public void process(MNSEvent cnv)
Description copied from interface: MNSListener
loads a CNSEvent into a listener

Specified by:
process in interface MNSListener
Overrides:
process in class BioSensor

initAll

public void initAll()
             throws java.io.IOException,
                    edu.cmu.sphinx.util.props.PropertyException,
                    java.lang.InstantiationException
Creates a new JSGFDemo. The demo will retrieve the configuration from the jsgf.config.xml file found in the classpath for the JSGFDemo. The jsgf.config.xml should at the minimum define a recognizer with the name 'recognizer', a JSGFGrammar named 'jsgfGrammar' and a Microphone named 'microphone'.

Throws:
java.io.IOException - if an I/O error occurs
edu.cmu.sphinx.util.props.PropertyException - if a property configuration occurs
java.lang.InstantiationException - if a problem occurs while creating any of the recognizer components.

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

execute

public void execute()
             throws java.io.IOException,
                    javax.speech.recognition.GrammarException
Executes the demo. The demo will cycle through four separate JSGF grammars,a 'movies' grammar, a 'news' grammar a 'books' grammar and a 'music' grammar. The news, books and movies grammars are loaded from the corresponding JSGF grammar file, while the music grammar is loaded from a file, but then augmented via RuleGrammar.setRule.

Throws:
java.io.IOException
javax.speech.recognition.GrammarException