SpeechRecognizerCallback

public interface SpeechRecognizerCallback


The callback interface for speech recognition.

Summary

Public methods

abstract void

Receives a notification of successful audio stream completion.

abstract void

Receives a GenAiException error from the audio stream.

abstract void

Receives a SpeechRecognizerResponse from the audio stream.

Public methods

onCompleted

abstract void onCompleted()

Receives a notification of successful audio stream completion.

May only be called once and if called it must be the last method called. In particular if an exception is thrown by an implementation of onCompleted no further calls to any method are allowed.

onError

abstract void onError(@NonNull GenAiException e)

Receives a GenAiException error from the audio stream.

May only be called once and if called it must be the last method called. In particular if an exception is thrown by an implementation of onError no further calls to any method are allowed.

Parameters
@NonNull GenAiException e

the error occurred on the stream

onNext

abstract void onNext(@NonNull SpeechRecognizerResponse response)

Receives a SpeechRecognizerResponse from the audio stream.

Can be called multiple times but is never called after onError or onCompleted are called.

Parameters
@NonNull SpeechRecognizerResponse response

the SpeechRecognizerResponse passed to the stream