com.nuance.nmdp.speechkit
Interface Recognizer


public interface Recognizer

The Recognizer object manages the entire recognition process including audio recording and server communication. Recognizer is designed to carry out a single recognition and may not be reused. Subsequent recognitions should each be generated by instantiating a new Recognizer instance.


Nested Class Summary
static class Recognizer.EndOfSpeechDetection
          These constants define the various end-of-speech detection models for the detection parameter of SpeechKit.createRecognizer(java.lang.String, int, java.lang.String, com.nuance.nmdp.speechkit.Recognizer.Listener, android.os.Handler)().
static interface Recognizer.Listener
          The Recognizer.Listener interface defines the callback methods called by a Recognizer object.
static class Recognizer.PromptType
          These constants define the types of prompts that can be played during recognition.
static class Recognizer.RecognizerType
          These strings are some of the possible values for the type parameter of SpeechKit.createRecognizer(java.lang.String, int, java.lang.String, com.nuance.nmdp.speechkit.Recognizer.Listener, android.os.Handler)().
 
Method Summary
 void cancel()
          Cancels the recognition request.
 float getAudioLevel()
          Get the average power of the most recent audio during recording.
 void setListener(Recognizer.Listener listener)
          Specify a new listener for the Recognizer object.
 void setPrompt(int promptType, Prompt p)
          Set an audio or vibration Prompt to play during this recognition.
 void start()
          Starts recording and streaming audio to the speech server.
 void stopRecording()
          Stops recording and streaming audio to the speech server.
 

Method Detail

setPrompt

void setPrompt(int promptType,
               Prompt p)
Set an audio or vibration Prompt to play during this recognition.

Parameters:
promptType - When to play the prompt. See Recognizer.PromptType.
p - The prompt to play. Use SpeechKit.defineAudioPrompt(int)() to create a prompt.

start

void start()
Starts recording and streaming audio to the speech server.

This method may only be called once for a Recognizer object.


stopRecording

void stopRecording()
Stops recording and streaming audio to the speech server.

This method is used to stop recording audio and continue with the recognition process. This method must be used when the end of speech detection is disabled and may be used with a end-of-speech detection model in order to allow a user to manually end a recording before the end-of-speech detector has activated.


cancel

void cancel()
Cancels the recognition request.

This method will terminate the recognition request, stopping any ongoing recording and terminating the recognition process. This will result in the recognizer listener receiving an error message via the Recognizer.Listener.onError(com.nuance.nmdp.speechkit.Recognizer, com.nuance.nmdp.speechkit.SpeechError)() method unless a recognition result has been received, or another error has already occurred.


getAudioLevel

float getAudioLevel()
Get the average power of the most recent audio during recording.

Returns:
The power level.

setListener

void setListener(Recognizer.Listener listener)
Specify a new listener for the Recognizer object.

This is especially useful when the object that created the original listener is no longer valid (e.g. an Activity has been destroyed and recreated by the Android OS due to the screen orientation changing). This method helps to ensure that subsequent callbacks will be processed by an up-to-date listener.

Parameters:
listener - The Recognizer.Listener for recognition responses. The listener will receive notifications when recording starts and stops, when a Recognition result is received, and when a SpeechError occurs.