RecognitionListener
  public
  
  
  
  interface
  RecognitionListener
  
  
  
| android.speech.RecognitionListener | 
Used for receiving notifications from the SpeechRecognizer when the recognition related events occur. All the callbacks are executed on the Application main thread.
Summary
| Public methods | |
|---|---|
| 
        abstract
        
        
        
        
        void | 
      onBeginningOfSpeech()
      The user has started to speak. | 
| 
        abstract
        
        
        
        
        void | 
      onBufferReceived(byte[] buffer)
      More sound has been received. | 
| 
        
        default
        
        
        
        void | 
      onEndOfSegmentedSession()
      Called at the end of a segmented recognition request. | 
| 
        abstract
        
        
        
        
        void | 
      onEndOfSpeech()
      Called after the user stops speaking. | 
| 
        abstract
        
        
        
        
        void | 
      onError(int error)
      A network or recognition error occurred. | 
| 
        abstract
        
        
        
        
        void | 
      onEvent(int eventType, Bundle params)
      Reserved for adding future events. | 
| 
        
        default
        
        
        
        void | 
      onLanguageDetection(Bundle results)
      Called when the language detection (and switching) results are available. | 
| 
        abstract
        
        
        
        
        void | 
      onPartialResults(Bundle partialResults)
      Called when partial recognition results are available. | 
| 
        abstract
        
        
        
        
        void | 
      onReadyForSpeech(Bundle params)
      Called when the endpointer is ready for the user to start speaking. | 
| 
        abstract
        
        
        
        
        void | 
      onResults(Bundle results)
      Called when recognition results are ready. | 
| 
        abstract
        
        
        
        
        void | 
      onRmsChanged(float rmsdB)
      The sound level in the audio stream has changed. | 
| 
        
        default
        
        
        
        void | 
      onSegmentResults(Bundle segmentResults)
      Called for each ready segment of a recognition request. | 
Public methods
onBeginningOfSpeech
public abstract void onBeginningOfSpeech ()
The user has started to speak.
onBufferReceived
public abstract void onBufferReceived (byte[] buffer)
More sound has been received. The purpose of this function is to allow giving feedback to the user regarding the captured audio. There is no guarantee that this method will be called.
| 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. | 
onEndOfSegmentedSession
public void onEndOfSegmentedSession ()
Called at the end of a segmented recognition request. To request segmented speech results
 use RecognizerIntent.EXTRA_SEGMENTED_SESSION.
onEndOfSpeech
public abstract void onEndOfSpeech ()
Called after the user stops speaking.
onError
public abstract void onError (int error)
A network or recognition error occurred.
| Parameters | |
|---|---|
| error | int: code is defined inSpeechRecognizer. Implementations need to handle any
              integer error constant to be passed here beyond constants prefixed with ERROR_.
 Value isSpeechRecognizer.ERROR_NETWORK_TIMEOUT,SpeechRecognizer.ERROR_NETWORK,SpeechRecognizer.ERROR_AUDIO,SpeechRecognizer.ERROR_SERVER,SpeechRecognizer.ERROR_CLIENT,SpeechRecognizer.ERROR_SPEECH_TIMEOUT,SpeechRecognizer.ERROR_NO_MATCH,SpeechRecognizer.ERROR_RECOGNIZER_BUSY,SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS,SpeechRecognizer.ERROR_TOO_MANY_REQUESTS,SpeechRecognizer.ERROR_SERVER_DISCONNECTED,SpeechRecognizer.ERROR_LANGUAGE_NOT_SUPPORTED,SpeechRecognizer.ERROR_LANGUAGE_UNAVAILABLE,SpeechRecognizer.ERROR_CANNOT_CHECK_SUPPORT, orSpeechRecognizer.ERROR_CANNOT_LISTEN_TO_DOWNLOAD_EVENTS | 
onEvent
public abstract void onEvent (int eventType, 
                Bundle params)Reserved for adding future events.
| Parameters | |
|---|---|
| eventType | int: the type of the occurred event | 
| params | Bundle: a Bundle containing the passed parameters | 
onLanguageDetection
public void onLanguageDetection (Bundle results)
Called when the language detection (and switching) results are available. This callback
 can be invoked on any number of occasions at any time between onBeginningOfSpeech()
 and onEndOfSpeech(), depending on the speech recognition service implementation.
 
 To request language detection,
 use RecognizerIntent.EXTRA_ENABLE_LANGUAGE_DETECTION.
 
 To request automatic language switching,
 use RecognizerIntent.EXTRA_ENABLE_LANGUAGE_SWITCH.
| Parameters | |
|---|---|
| results | Bundle: the returned language detection (and switching) results. To retrieve the most confidently detected language IETF tag
        (as defined by BCP 47, e.g., "en-US", "de-DE"),
        use   To retrieve the language detection confidence level represented by a value
        prefixed by   To retrieve the alternative locales for the same language
        retrieved by the key   To retrieve the language switching results represented by a value
        prefixed by  | 
onPartialResults
public abstract void onPartialResults (Bundle partialResults)
Called when partial recognition results are available. The callback might be called at any
 time between onBeginningOfSpeech() and onResults(android.os.Bundle) when partial
 results are ready. This method may be called zero, one or multiple times for each call to
 SpeechRecognizer.startListening(Intent), depending on the speech recognition
 service implementation.  To request partial results, use
 RecognizerIntent.EXTRA_PARTIAL_RESULTS
| Parameters | |
|---|---|
| partialResults | Bundle: the returned results. To retrieve the results in
        ArrayList<String> format useBundle.getStringArrayList(String)withSpeechRecognizer.RESULTS_RECOGNITIONas a parameter | 
onReadyForSpeech
public abstract void onReadyForSpeech (Bundle params)
Called when the endpointer is ready for the user to start speaking.
| Parameters | |
|---|---|
| params | Bundle: parameters set by the recognition service. Reserved for future use. | 
onResults
public abstract void onResults (Bundle results)
Called when recognition results are ready.
     Called with the results for the full speech since onReadyForSpeech(android.os.Bundle).
     To get recognition results in segments rather than for the full session see
     RecognizerIntent.EXTRA_SEGMENTED_SESSION.
 
| Parameters | |
|---|---|
| results | Bundle: the recognition results. To retrieve the results inArrayList<String>format useBundle.getStringArrayList(String)withSpeechRecognizer.RESULTS_RECOGNITIONas a parameter. A float array of
        confidence values might also be given inSpeechRecognizer.CONFIDENCE_SCORES. | 
onRmsChanged
public abstract void onRmsChanged (float rmsdB)
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 | 
onSegmentResults
public void onSegmentResults (Bundle segmentResults)
Called for each ready segment of a recognition request. To request segmented speech results
 use RecognizerIntent.EXTRA_SEGMENTED_SESSION. The callback might be called
 any number of times between onReadyForSpeech(android.os.Bundle) and
 onEndOfSegmentedSession().
| Parameters | |
|---|---|
| segmentResults | Bundle: the returned results. To retrieve the results in
        ArrayList<String> format useBundle.getStringArrayList(String)withSpeechRecognizer.RESULTS_RECOGNITIONas a parameter
 This value cannot benull. | 
