| java.lang.Object | |
| ↳ | android.speech.SpeechRecognizer | 
       This class provides access to the speech recognition service. This service allows access to the
 speech recognizer. Do not instantiate this class directly, instead, call
       
        
         createSpeechRecognizer(Context)
        
       
       . This class's methods must be
 invoked only from the main application thread.
      
The implementation of this API is likely to stream audio to remote servers to perform speech recognition. As such this API is not intended to be used for continuous recognition, which would consume a significant amount of battery and bandwidth.
       Please note that the application must have
       
        
         RECORD_AUDIO
        
       
       permission to use this class.
      
| Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| String | CONFIDENCE_SCORES | 
         Key used to retrieve a float array from the
         
          
           Bundle
          
         
         passed to the
         
          
           onResults(Bundle)
          
         
         and
         
          
           onPartialResults(Bundle)
          
         
         methods.
         | 
       |||||||||
| int | ERROR_AUDIO | Audio recording error. | |||||||||
| int | ERROR_CLIENT | Other client side errors. | |||||||||
| int | ERROR_INSUFFICIENT_PERMISSIONS | Insufficient permissions | |||||||||
| int | ERROR_NETWORK | Other network related errors. | |||||||||
| int | ERROR_NETWORK_TIMEOUT | Network operation timed out. | |||||||||
| int | ERROR_NO_MATCH | No recognition result matched. | |||||||||
| int | ERROR_RECOGNIZER_BUSY | RecognitionService busy. | |||||||||
| int | ERROR_SERVER | Server sends error status. | |||||||||
| int | ERROR_SPEECH_TIMEOUT | No speech input | |||||||||
| String | RESULTS_RECOGNITION | 
         Key used to retrieve an
         
          ArrayList
          
         from the
         
          
           Bundle
          
         
         passed to the
         
          
           onResults(Bundle)
          
         
         and
         
          
           onPartialResults(Bundle)
          
         
         methods.
         | 
       |||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| 
          | 
        
          
          Cancels the speech recognition.
          
         | 
       ||||||||||
| 
          | 
        
          
          Factory method to create a new
           
        
           SpeechRecognizer
          
          .
          | 
       ||||||||||
| 
          | 
        
          
          Factory method to create a new
           
        
           SpeechRecognizer
          
          .
          | 
       ||||||||||
| 
          | 
        
          
          Destroys the
           
        
           SpeechRecognizer
          
          object.
          | 
       ||||||||||
| 
          | 
        
          
          Checks whether a speech recognition service is available on the system.
          
         | 
       ||||||||||
| 
          | 
        
          
          Sets the listener that will receive all the callbacks.
          
         | 
       ||||||||||
| 
          | 
        
          
          Starts listening for speech.
          
         | 
       ||||||||||
| 
          | 
        
          
          Stops listening for speech.
          
         | 
       ||||||||||
| 
         
          [Expand]
         
          
          Inherited Methods
          
         | 
       |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
         
           
         
         From class
         
          java.lang.Object
         
          | 
       |||||||||||
         Key used to retrieve a float array from the
         
          
           Bundle
          
         
         passed to the
         
          
           onResults(Bundle)
          
         
         and
         
          
           onPartialResults(Bundle)
          
         
         methods. The array should be
 the same size as the ArrayList provided in
         
          
           RESULTS_RECOGNITION
          
         
         , and should contain
 values ranging from 0.0 to 1.0, or -1 to represent an unavailable confidence score.
        
Confidence values close to 1.0 indicate high confidence (the speech recognizer is confident that the recognition result is correct), while values close to 0.0 indicate low confidence.
This value is optional and might not be provided.
Audio recording error.
Other client side errors.
Insufficient permissions
Other network related errors.
Network operation timed out.
No recognition result matched.
RecognitionService busy.
Server sends error status.
No speech input
         Key used to retrieve an
         
          ArrayList
          
         from the
         
          
           Bundle
          
         
         passed to the
         
          
           onResults(Bundle)
          
         
         and
         
          
           onPartialResults(Bundle)
          
         
         methods. These strings are the possible
 recognition results, where the first element is the most likely candidate.
        
         Cancels the speech recognition. Please note that
         
          
           setRecognitionListener(RecognitionListener)
          
         
         should be called beforehand, otherwise
 no notifications will be received.
        
         Factory method to create a new
         
          SpeechRecognizer
         
         . Please note that
         
          
           setRecognitionListener(RecognitionListener)
          
         
         should be called before dispatching any
 command to the created
         
          SpeechRecognizer
         
         , otherwise no notifications will be
 received.
 Use this version of the method to specify a specific service to direct this
         
          
           SpeechRecognizer
          
         
         to. Normally you would not use this; use
         
          
           createSpeechRecognizer(Context)
          
         
         instead to use the system default recognition
 service.
        
| context | 
           in which to create
           
            SpeechRecognizer
           
           | 
         
|---|---|
| serviceComponent | 
           the
           
            
             ComponentName
            
           
           of a specific service to direct this
           
            SpeechRecognizer
           
           to
           | 
         
           SpeechRecognizer
          
         
         Factory method to create a new
         
          SpeechRecognizer
         
         . Please note that
         
          
           setRecognitionListener(RecognitionListener)
          
         
         should be called before dispatching any
 command to the created
         
          SpeechRecognizer
         
         , otherwise no notifications will be
 received.
        
| context | 
           in which to create
           
            SpeechRecognizer
           
           | 
         
|---|
           SpeechRecognizer
          
         
         Checks whether a speech recognition service is available on the system. If this method
 returns
         
          false
         
         ,
         
          
           createSpeechRecognizer(Context)
          
         
         will
 fail.
        
| context | 
           with which
           
            SpeechRecognizer
           
           will be created
           | 
         
|---|
           true
          
          if recognition is available,
          
           false
          
          otherwise
         Sets the listener that will receive all the callbacks. The previous unfinished commands will be executed with the old listener, while any following command will be executed with the new listener.
| listener | 
           listener that will receive all the callbacks from the created
           
            
             SpeechRecognizer
            
           
           , this must not be null.
           | 
         
|---|
         Starts listening for speech. Please note that
         
          
           setRecognitionListener(RecognitionListener)
          
         
         should be called beforehand, otherwise
 no notifications will be received.
        
| recognizerIntent | 
           contains parameters for the recognition to be performed. The intent
        may also contain optional extras, see
           
            
             RecognizerIntent
            
           
           . If these values are
        not set explicitly, default values will be used by the recognizer.
           | 
         
|---|
         Stops listening for speech. Speech captured so far will be recognized as if the user had
 stopped speaking at this point. Note that in the default case, this does not need to be
 called, as the speech endpointer will automatically stop the recognizer listening when it
 determines speech has completed. However, you can manipulate endpointer parameters directly
 using the intent extras defined in
         
          
           RecognizerIntent
          
         
         , in which case you may sometimes
 want to manually call this method to stop listening sooner. Please note that
         
          
           setRecognitionListener(RecognitionListener)
          
         
         should be called beforehand, otherwise
 no notifications will be received.