Overview | Package | Class | Tree | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class javax.speech.recognition.RecognizerAudioEvent

java.lang.Object
  |
  +--java.util.EventObject
        |
        +--javax.speech.SpeechEvent
              |
              +--javax.speech.AudioEvent
                    |
                    +--javax.speech.recognition.RecognizerAudioEvent

public class RecognizerAudioEvent
extends AudioEvent
Event issued to indicate detection of speech in the incoming audio stream or to periodically indicate the audio input level. RecognizerAudioEvents are issued to each RecognizerAudioListener attached to the AudioManager for a Recognizer.

RecognizerAudioListener events are timed with the input audio. In most architectures this indicates that the events occur in near to real time.

SPEECH_STARTED and SPEECH_STOPPED

The SPEECH_STARTED and SPEECH_STOPPED events are used to indicate possible detection of speech in the incoming audio. Applications may use this event to display visual feedback to a user indicating that the recognizer is listening - for example, by maintaining a icon indicating microphone status.

It is sometimes difficult to quickly distinguish between speech and other noises (e.g. coughs, microphone bumps), so the SPEECH_STARTED event is not always followed by a Result.

If a RESULT_CREATED is issued for the detected speech, it will usually occur soon after the SPEECH_STARTED event but may be delayed for a number of reasons.

Some recognizers will allow a user to speak more than one commands without a break. In these cases, a single SPEECH_STARTED event may be followed by more than one RESULT_CREATED event and result finalization before the SPEECH_STOPPED event is issued.

In longer speech (e.g. dictating a paragraph), short pauses in the user's speech may lead to a SPEECH_STOPPED event followed by a SPEECH_STARTED event as the user resumes speaking. These events do not always indicate that the current result will be finalized.

In short, applications should treat the SPEECH_STARTED and SPEECH_STOPPED events as operating entirely independently from the result system of a Recognizer.

Audio Level Events

An AUDIO_LEVEL event indicates a change in the volume of the audio input to a recognizer. The level is defined on a scale from 0 to 1. 0.0 represents silence. 0.25 represents quiet input. 0.75 represents loud input. 1.0 indicates the maximum level.

Audio level events are suitable for display of a visual "VU meter" (like the bar on stereo systems which goes up and down with the volume). Different colors are often used to indicate the different levels: for example, red for loud, green for normal, and blue for background.

Maintaining audio quality is important for reliable recognition. A common problem is a user speaking too loudly or too quietly. The color on a VU meter is one way to provide feedback to the user. Note that a quiet level (below 0.25) does not necessarily indicate that the user is speaking too quietly. The input is also quiet when the user is not speaking.

See Also:
Recognizer, AudioManager, RecognizerAudioListener, RESULT_CREATED, Serialized Form

Field Summary
static int AUDIO_LEVEL
          AUDIO_LEVEL event indicates a change in the volume level of the incoming audio.
float audioLevel
          Audio level defined on a scale from 0 to 1.

static int SPEECH_STARTED
          The recognizer has detected the possible start of speech in the incoming audio.
static int SPEECH_STOPPED
          The recognizer has detected the end of speech or noise in the incoming audio that it previously indicated by a SPEECH_STARTED event.
 
Fields inherited from class javax.speech.SpeechEvent
id
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
RecognizerAudioEvent(Recognizer source, int id, float audioLevel)
          Constructs an RecognizerAudioEvent with a specified event identifier and audio level.
RecognizerAudioEvent(Recognizer source, int id)
          Constructs an RecognizerAudioEvent with a specified event identifier.
 
Method Summary
float getAudioLevel()
          Get the audio input level in the range 0 to 1. A value below 0.25 indicates quiet input with 0.0 being silence.
String paramString()
          Returns a parameter string identifying this event.
 
Methods inherited from class javax.speech.AudioEvent
paramString
 
Methods inherited from class javax.speech.SpeechEvent
getId, paramString, toString
 
Methods inherited from class java.util.EventObject
getSource, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Field Detail

SPEECH_STARTED

public static final int SPEECH_STARTED
The recognizer has detected the possible start of speech in the incoming audio. Applications may use this event to display visual feedback to a user indicating that the recognizer is listening.

A detailed description of SPEECH_STARTED and SPEECH_STOPPED events is provided above.

See Also:
speechStarted, getId, SPEECH_STOPPED

SPEECH_STOPPED

public static final int SPEECH_STOPPED
The recognizer has detected the end of speech or noise in the incoming audio that it previously indicated by a SPEECH_STARTED event. This event always follows a SPEECH_STARTED event.

A detailed description of SPEECH_STARTED and SPEECH_STOPPED events is provided above.

See Also:
speechStopped, SPEECH_STARTED, getId

AUDIO_LEVEL

public static final int AUDIO_LEVEL
AUDIO_LEVEL event indicates a change in the volume level of the incoming audio. A detailed description of the AUDIO_LEVEL event is provided above.

See Also:
audioLevel

audioLevel

protected float audioLevel
Audio level defined on a scale from 0 to 1.

See Also:
getAudioLevel
Constructor Detail

RecognizerAudioEvent

public RecognizerAudioEvent(Recognizer source,
                            int id,
                            float audioLevel)
Constructs an RecognizerAudioEvent with a specified event identifier and audio level. The audioLevel should be 0.0 for SPEECH_STARTED and SPEECH_STOPPED events.
Parameters:
source - the Recognizer that issued the event
id - the identifier for the event type
audioLevel - the audio level for this event

RecognizerAudioEvent

public RecognizerAudioEvent(Recognizer source,
                            int id)
Constructs an RecognizerAudioEvent with a specified event identifier. The audioLevel is set to 0.0.
Parameters:
source - the Recognizer that issued the event
id - the identifier for the event type
Method Detail

getAudioLevel

public float getAudioLevel()
Get the audio input level in the range 0 to 1. A value below 0.25 indicates quiet input with 0.0 being silence. A value above 0.75 indicates loud input with 1.0 indicating the maximum level.

The level is provided only for the AUDIO_LEVEL event type. The level should be ignored for SPEECH_STARTED and SPEECH_STOPPED events.

See Also:
AUDIO_LEVEL

paramString

public String paramString()
Returns a parameter string identifying this event. This method is useful for event-logging and for debugging.

Returns:
a string identifying the event
Overrides:
paramString in class AudioEvent

Overview | Package | Class | Tree | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

JavaTM Speech API
Copyright 1997-1998 Sun Microsystems, Inc. All rights reserved
Send comments to javaspeech-comments@sun.com