Interface RecognizerListener

ru.yandex.speechkit

public  interface  RecognizerListener 

The interface defines callback methods that are invoked during the recognition lifecycle.

The object that implements the interface is notified of the start of recording, a new chunk of audio data, the completion of the recognition process (either successful or with an error), and of other events.

Methods

voidonMusicResults(@NonNull final Recognizer recognizer, @NonNull final Track track)

Called when the music recognition result is received.

voidonPartialResults(@NonNull final Recognizer recognizer, @NonNull final Recognition results, final boolean endOfUtterance)

Called when an intermediate recognition result is received.

voidonPowerUpdated(@NonNull final Recognizer recognizer, final float power)

Called each time after recording a chunk of audio data, and is used for updating the speech power indicator in the user interface.

voidonRecognitionDone(@NonNull final Recognizer recognizer)

Called if the recognition process completed successfully.

voidonRecognizerError(@NonNull final Recognizer recognizer, @NonNull final Error error)

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

voidonRecordingBegin(@NonNull final Recognizer recognizer)

Called when audio recording starts.

voidonRecordingDone(@NonNull final Recognizer recognizer)

Called when audio recording stops.

voidonSpeechDetected(@NonNull final Recognizer recognizer)

Called when the detection of speech starts (the user begins to speak).

voidonSpeechEnds(@NonNull final Recognizer recognizer)

Called when the user finished speaking.

Method Detail

onMusicResults

public void onMusicResults (@NonNull final Recognizer recognizer, @NonNull final Track track)

Called when the music recognition result is received.

This method is called if the setEnableMusicRecognition (boolean) setting is enabled.
Parameters:
recognizer

Link to the object of the Recognizer class that invoked the method.

track

Music recognition result.

onPartialResults

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

Called when an intermediate recognition result is received.

The method can be called multiple times after recognition begins. The method is passed a part of the recognition result and the end of utterance flag. If endOfUtterance = true, the results parameter contains the final recognition result.
Parameters:
recognizer

Link to the object of the Recognizer class that invoked the method.

results

Partial recognition result.

endOfUtterance

End of utterance flag. Acceptable values: true - the end of the utterance is detected; false - the utterance is not yet complete.

onPowerUpdated

public void onPowerUpdated (@NonNull final Recognizer recognizer, final float power)

Called each time after recording a chunk of audio data, and is used for updating the speech power indicator in the user interface.

Parameters:
recognizer

Link to the object of the Recognizer class that invoked the method.

power

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

onRecognitionDone

public void onRecognitionDone (@NonNull final Recognizer recognizer)

Called if the recognition process completed successfully.

The method is called if the speech was recognized successfully. Otherwise, onRecognizerError (Recognizer, Error) is called.
Parameters:
recognizer

Link to the object of the Recognizer class that invoked the method.

onRecognizerError

public void onRecognizerError (@NonNull final Recognizer recognizer, @NonNull final Error error)

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

Errors can occur for various 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), and so on.
Parameters:
recognizer

Link to the object of the Recognizer class that invoked the method.

error

Error during speech recognition.

onRecordingBegin

public void onRecordingBegin (@NonNull final Recognizer recognizer)

Called when audio recording starts.

Parameters:
recognizer

Link to the object of the Recognizer class that invoked the method.

onRecordingDone

public void onRecordingDone (@NonNull final Recognizer recognizer)

Called when audio recording stops.

Parameters:
recognizer

Link to the object of the Recognizer class that invoked the method.

onSpeechDetected

public void onSpeechDetected (@NonNull final Recognizer recognizer)

Called when the detection of speech starts (the user begins to speak).

The method is called if the VAD is enabled. The VAD is enabled by default. Use the setVadEnabled(boolean) method to enable or disable the VAD.
Parameters:
recognizer

Link to the object of the Recognizer class that invoked the method.

onSpeechEnds

public void onSpeechEnds (@NonNull final Recognizer recognizer)

Called when the user finished speaking.

The method is called if the VAD is enabled. The VAD is enabled by default. Use the setVadEnabled(boolean) method to enable or disable the VAD.
Parameters:
recognizer

Link to the object of the Recognizer class that invoked the method.