RecognizerListener interface

ru.yandex.speechkit

public  interface  RecognizerListener 

The interface implements:
RecognizerActivity

The interface defines callback methods that are called by the recognizer.

These callbacks are called during speech recognition for notification of events, such as when recording has started, a new portion of audio data has been recorded, the recognition process has finished (successfully or with an error), and other events.

Methods

voidonError(Recognizer recognizer, Error error)

Called when the recognition process failed with an error.

voidonPartialResults(Recognizer recognizer, Recognition results, boolean endOfUtterance)

Called when a partial result is received.

voidonPowerUpdated(Recognizer recognizer, float power)

Called for updating the power of the speech signal.

voidonRecognitionDone(Recognizer recognizer, Recognition results)

Called when the recognition process completes successfully.

voidonRecordingBegin(Recognizer recognizer)

Called when Recognizer has started recording audio.

voidonRecordingDone(Recognizer recognizer)

Called when Recognizer has finished recording audio.

voidonSoundDataRecorded(Recognizer recognizer, byte[] data)

Called when a chunk of audio data has been recorded.

voidonSpeechDetected(Recognizer recognizer)

Called when the user has started speaking (when speech was detected in the audio stream).

Method descriptions

onError

public void onError (Recognizer recognizer, Error error)

Called when the recognition process failed with an error.

Errors can occur for a number of reasons: an error opening the audio device, an error communicating with the server, an invalid parameter value passed during initialization (for example, the language code or authentication data), the user canceling the request, and so on.
Parameters:
error

Error during speech recognition.

Note.

This method is called only if speech recognition failed with an error.

onPartialResults

public void onPartialResults (Recognizer recognizer, Recognition results, boolean endOfUtterance)

Called when a partial result is received.

This method is called when a partial recognition result is received. It can be called any number of times after recognition has started and before it finishes. In addition to the result itself, this method is passed a flag that is set to true when the end of the "utterance" is detected. Speech is divided into utterances based on the length of pauses between words (this algorithm may be changed in future versions).
Parameters:
results

Partial recognition result.

endOfUtterance

Set to true if the end of an utterance was detected.

onPowerUpdated

public void onPowerUpdated (Recognizer recognizer, float power)

Called for updating the power of the speech signal.

This method is called each time after recording a chunk of audio data, and is used for updating the speech power indicator in the user interface.
Parameters:
power

A fractional number between 0 and 1 indicating the power of the signal (0 means no signal, and 1 is the maximum signal).

Note.

The function is called even if the power has not changed.

onRecognitionDone

public void onRecognitionDone (Recognizer recognizer, Recognition results)

Called when the recognition process completes successfully.

This is the mechanism used by Recognizer to provide recognition results. The method is called only if speech was recognized successfully. Otherwise, onError() is called.
Parameters:
results

Recognition result.

onRecordingBegin

public void onRecordingBegin (Recognizer recognizer)

Called when Recognizer has started recording audio.

onRecordingDone

public void onRecordingDone (Recognizer recognizer)

Called when Recognizer has finished recording audio.

onSoundDataRecorded

public void onSoundDataRecorded (Recognizer recognizer, byte[] data)

Called when a chunk of audio data has been recorded.

Parameters:
data

Raw audio data recorded from the audio device.

Note.

The sample width and rate are unspecified and may change.

onSpeechDetected

public void onSpeechDetected (Recognizer recognizer)

Called when the user has started speaking (when speech was detected in the audio stream).

Note.

This method is only called if the Voice Activity Detector (VAD) is enabled.