SpeechRecognizerCallback

interface SpeechRecognizerCallback


The callback interface for speech recognition.

Summary

Public functions

Unit

Receives a notification of successful audio stream completion.

Unit

Receives a GenAiException error from the audio stream.

Unit

Receives a SpeechRecognizerResponse from the audio stream.

Public functions

onCompleted

fun onCompleted(): Unit

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

fun onError(e: GenAiException): Unit

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
e: GenAiException

the error occurred on the stream

onNext

fun onNext(response: SpeechRecognizerResponse): Unit

Receives a SpeechRecognizerResponse from the audio stream.

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

Parameters
response: SpeechRecognizerResponse

the SpeechRecognizerResponse passed to the stream