RecognizerListener interface

ru.yandex.speechkit

public interface RecognizerListener 

The interface implements:
RecognizerActivity

This interface defines the callback methods of the listener called by Recognizer.

These callback methods are called during the lifecycle of a Recognizer object. The listener will be notified when recording started, a new audio fragment was recorded, the recognition process finished (sucessfully or with an error), and about other events.

Methods

voidonError(Recognizer recognizer, Error error)

Called when the recognition process failed with an error (Error).

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 the recognizer began recording sound.

voidonRecordingDone(Recognizer recognizer)

Called when the recognizer finished recording sound.

voidonSoundDataRecorded(Recognizer recognizer, byte[] data)

Called when a chunk of audio data has been recorded.

voidonSpeechDetected(Recognizer recognizer)

Called when the user started speaking.

Method descriptions

onError

public void onError (Recognizer recognizer, Error error)

Called when the recognition process failed with an error (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), cancellation of the request by the user, and so on. The reason for the error is passed by the function parameter. The method is called only if recognition failed with an error. Otherwise, onRecognitionDone() is called.
Parameters:
error

Error during speech recognition.

onPowerUpdated

public void onPowerUpdated (Recognizer recognizer, float power)

Called for updating the power of the speech signal.

The function is called on every new chunk of audio data and should be used to update the voice 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 the recognizer to provide recognition results. The method is called only if speech was recognized successfully. Otherwise, onError() is called.
Parameters:
results

the result of recognition.

onRecordingBegin

public void onRecordingBegin (Recognizer recognizer)

Called when the recognizer began recording sound.

onRecordingDone

public void onRecordingDone (Recognizer recognizer)

Called when the recognizer finished recording sound.

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 started speaking.

Note.

This method is only called when the voice activity detector (VAD) is enabled at the moment when speech was detected.