def METHOD_NAME(self):
    intent = Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH)
    intent.putExtra(
        RecognizerIntent.EXTRA_CALLING_PACKAGE,
        activity.getPackageName()
    )
    # language preferences
    intent.putExtra(
        RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, self.language
    )
    intent.putExtra(
        RecognizerIntent.EXTRA_LANGUAGE_MODEL,
        RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH
    )
    # results settings
    intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 1000)
    intent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, True)
    if self.prefer_offline:
        intent.putExtra(RecognizerIntent.EXTRA_PREFER_OFFLINE, True)
    # listener and callbacks
    listener = SpeechListener()
    listener.error_callback = self._on_error
    listener.result_callback = self._on_result
    listener.partial_result_callback = self._on_partial
    # create recognizer and start
    self.speech = SpeechRecognizer.createSpeechRecognizer(activity)
    self.speech.setRecognitionListener(listener)
    self.speech.startListening(intent)