Most visited

Recently visited

Added in API level 8

RecognitionService.Callback

public class RecognitionService.Callback
extends Object

java.lang.Object
   ↳ android.speech.RecognitionService.Callback


This class receives callbacks from the speech recognition service and forwards them to the user. An instance of this class is passed to the onStartListening(Intent, Callback) method. Recognizers may call these methods on any thread.

Summary

Public methods

void beginningOfSpeech()

The service should call this method when the user has started to speak.

void bufferReceived(byte[] buffer)

The service should call this method when sound has been received.

void endOfSpeech()

The service should call this method after the user stops speaking.

void error(int error)

The service should call this method when a network or recognition error occurred.

int getCallingUid()

Return the Linux uid assigned to the process that sent you the current transaction that is being processed.

void partialResults(Bundle partialResults)

The service should call this method when partial recognition results are available.

void readyForSpeech(Bundle params)

The service should call this method when the endpointer is ready for the user to start speaking.

void results(Bundle results)

The service should call this method when recognition results are ready.

void rmsChanged(float rmsdB)

The service should call this method when the sound level in the audio stream has changed.

Inherited methods

From class java.lang.Object

Public methods

beginningOfSpeech

Added in API level 8
void beginningOfSpeech ()

The service should call this method when the user has started to speak.

Throws
RemoteException

bufferReceived

Added in API level 8
void bufferReceived (byte[] buffer)

The service should call this method when sound has been received. The purpose of this function is to allow giving feedback to the user regarding the captured audio.

Parameters
buffer byte: a buffer containing a sequence of big-endian 16-bit integers representing a single channel audio stream. The sample rate is implementation dependent.
Throws
RemoteException

endOfSpeech

Added in API level 8
void endOfSpeech ()

The service should call this method after the user stops speaking.

Throws
RemoteException

error

Added in API level 8
void error (int error)

The service should call this method when a network or recognition error occurred.

Parameters
error int: code is defined in SpeechRecognizer
Throws
RemoteException

getCallingUid

Added in API level 23
int getCallingUid ()

Return the Linux uid assigned to the process that sent you the current transaction that is being processed. This is obtained from getCallingUid().

Returns
int

partialResults

Added in API level 8
void partialResults (Bundle partialResults)

The service should call this method when partial recognition results are available. This method can be called at any time between beginningOfSpeech() and results(Bundle) when partial results are ready. This method may be called zero, one or multiple times for each call to startListening(Intent), depending on the speech recognition service implementation.

Parameters
partialResults Bundle: the returned results. To retrieve the results in ArrayList<String> format use getStringArrayList(String) with RESULTS_RECOGNITION as a parameter
Throws
RemoteException

readyForSpeech

Added in API level 8
void readyForSpeech (Bundle params)

The service should call this method when the endpointer is ready for the user to start speaking.

Parameters
params Bundle: parameters set by the recognition service. Reserved for future use.
Throws
RemoteException

results

Added in API level 8
void results (Bundle results)

The service should call this method when recognition results are ready.

Parameters
results Bundle: the recognition results. To retrieve the results in ArrayList<String> format use getStringArrayList(String) with RESULTS_RECOGNITION as a parameter
Throws
RemoteException

rmsChanged

Added in API level 8
void rmsChanged (float rmsdB)

The service should call this method when the sound level in the audio stream has changed. There is no guarantee that this method will be called.

Parameters
rmsdB float: the new RMS dB value
Throws
RemoteException

Hooray!