public interface RecognitionCallback

Known subtypesRecognitionCallback.Adapter, TimedRecognitionCallback, TimedRecognitionCallback.Adapter

Listener for SpeechRecognizer results. Every method is invoked on the EDT.

Nested types

class RecognitionCallback.AdapterNo-op adapter.

Methods

public abstract void onPartialResult(String transcript)Best-effort transcript while the user is still speaking.
public abstract void onResult(String transcript, float confidence, String[] alternatives)Final transcript for a single utterance.
public abstract void onEnd()Recognition session ended (timeout, mic released, or SpeechRecognizer.stop()).
public abstract void onError(Throwable t)Recognition failed (no permission, no network for online engines, hardware error).

Method details

onPartialResult

public abstract void onPartialResult(String transcript)
Best-effort transcript while the user is still speaking. May fire many times before onResult. Skip overriding if RecognitionOptions.setPartialResults(false) was passed.

onResult

public abstract void onResult(String transcript, float confidence, String[] alternatives)
Final transcript for a single utterance. confidence is in [0.0, 1.0] when the platform supplies one, or -1 when it doesn’t. alternatives may be empty.

onEnd

public abstract void onEnd()
Recognition session ended (timeout, mic released, or SpeechRecognizer.stop()). No more callbacks will fire.

onError

public abstract void onError(Throwable t)
Recognition failed (no permission, no network for online engines, hardware error).