	private void setUpRecognizerGui(final SpeechRecognizer sr, final Intent intentRecognizer) {
		final AudioCue audioCue;
		if (mPrefs.getBoolean(getString(R.string.keyAudioCues), mRes.getBoolean(R.bool.defaultAudioCues))) {
			audioCue = new AudioCue(this);
		} else {
			audioCue = null;
		}
		sr.setRecognitionListener(new RecognitionListener() {
			@Override
			public void onBeginningOfSpeech() {
				mState = State.LISTENING;
			}
			@Override
			public void onBufferReceived(byte[] buffer) {
			}
			@Override
			public void onEndOfSpeech() {
				mState = State.TRANSCRIBING;
				mButtonMicrophone.setState(mState);
				if (audioCue != null) {
					audioCue.playStopSound();
				}
			}
			@Override
			public void onError(int error) {
				mState = State.ERROR;
				mButtonMicrophone.setState(mState);
				if (audioCue != null) {
					audioCue.playErrorSound();
				}
				switch (error) {
				case SpeechRecognizer.ERROR_AUDIO:
					showErrorDialog(R.string.errorResultAudioError);
					break;
				case SpeechRecognizer.ERROR_CLIENT:
					showErrorDialog(R.string.errorResultClientError);
					break;
				case SpeechRecognizer.ERROR_NETWORK:
					showErrorDialog(R.string.errorResultNetworkError);
					break;
				case SpeechRecognizer.ERROR_NETWORK_TIMEOUT:
					showErrorDialog(R.string.errorResultNetworkError);
					break;
				case SpeechRecognizer.ERROR_SERVER:
					showErrorDialog(R.string.errorResultServerError);
					break;
				case SpeechRecognizer.ERROR_RECOGNIZER_BUSY:
					showErrorDialog(R.string.errorResultServerError);
					break;
				case SpeechRecognizer.ERROR_NO_MATCH:
					showErrorDialog(R.string.errorResultNoMatch);
					break;
				case SpeechRecognizer.ERROR_SPEECH_TIMEOUT:
					showErrorDialog(R.string.errorResultNoMatch);
					break;
				case SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS:
					break;
				default:
					break;
				}
			}
			@Override
			public void onEvent(int eventType, Bundle params) {
			}
			@Override
			public void onPartialResults(Bundle partialResults) {
			}
			@Override
			public void onReadyForSpeech(Bundle params) {
				mState = State.RECORDING;
				mButtonMicrophone.setState(mState);
			}
			@Override
			public void onResults(Bundle results) {
				mState = State.INIT;
				mButtonMicrophone.setState(mState);
				onSuccess(intentRecognizer.getStringExtra(RecognizerIntent.EXTRA_LANGUAGE), results);
			}
			@Override
			public void onRmsChanged(float rmsdB) {
				mButtonMicrophone.setVolumeLevel(rmsdB);
			}
		});
		mButtonMicrophone.setOnTouchListener(new View.OnTouchListener() {
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				if (event.getAction() == MotionEvent.ACTION_DOWN) {
					vibrate();
				}
				return false;
			}
		});
		mButtonMicrophone.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				if (mState == State.INIT || mState == State.ERROR) {
					mTts.stop();
					if (audioCue != null) {
						audioCue.playStartSoundAndSleep();
					}
					sr.startListening(intentRecognizer);
				}
				else if (mState == State.RECORDING) {
				}
				else if (mState == State.TRANSCRIBING) {
				}
				else if (mState == State.LISTENING) {
					sr.stopListening();
				} else {
				}
			}
		});
		LinearLayout llMicrophone = (LinearLayout) findViewById(R.id.llMicrophone);
		llMicrophone.setVisibility(View.VISIBLE);
		llMicrophone.setEnabled(true);
	}

	private void setUpRecognizerGui(final SpeechRecognizer sr, final Intent intentRecognizer) {
		final AudioCue audioCue;
		if (mPrefs.getBoolean(getString(R.string.keyAudioCues), mRes.getBoolean(R.bool.defaultAudioCues))) {
			audioCue = new AudioCue(this);
		} else {
			audioCue = null;
		}
		sr.setRecognitionListener(new RecognitionListener() {
			@Override
			public void onBeginningOfSpeech() {
				mState = State.LISTENING;
			}
			@Override
			public void onBufferReceived(byte[] buffer) {
			}
			@Override
			public void onEndOfSpeech() {
				mState = State.TRANSCRIBING;
				mButtonMicrophone.setState(mState);
				if (audioCue != null) {
					audioCue.playStopSound();
				}
			}
			@Override
			public void onError(int error) {
				mState = State.ERROR;
				mButtonMicrophone.setState(mState);
				if (audioCue != null) {
					audioCue.playErrorSound();
				}
				switch (error) {
				case SpeechRecognizer.ERROR_AUDIO:
					showErrorDialog(R.string.errorResultAudioError);
					break;
				case SpeechRecognizer.ERROR_CLIENT:
					showErrorDialog(R.string.errorResultClientError);
					break;
				case SpeechRecognizer.ERROR_NETWORK:
					showErrorDialog(R.string.errorResultNetworkError);
					break;
				case SpeechRecognizer.ERROR_NETWORK_TIMEOUT:
					showErrorDialog(R.string.errorResultNetworkError);
					break;
				case SpeechRecognizer.ERROR_SERVER:
					showErrorDialog(R.string.errorResultServerError);
					break;
				case SpeechRecognizer.ERROR_RECOGNIZER_BUSY:
					showErrorDialog(R.string.errorResultServerError);
					break;
				case SpeechRecognizer.ERROR_NO_MATCH:
					showErrorDialog(R.string.errorResultNoMatch);
					break;
				case SpeechRecognizer.ERROR_SPEECH_TIMEOUT:
					showErrorDialog(R.string.errorResultNoMatch);
					break;
				case SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS:
					break;
				default:
					break;
				}
			}
			@Override
			public void onEvent(int eventType, Bundle params) {
			}
			@Override
			public void onPartialResults(Bundle partialResults) {
			}
			@Override
			public void onReadyForSpeech(Bundle params) {
				mState = State.RECORDING;
				mButtonMicrophone.setState(mState);
			}
			@Override
			public void onResults(Bundle results) {
				mState = State.INIT;
				mButtonMicrophone.setState(mState);
				onSuccess(intentRecognizer.getStringExtra(RecognizerIntent.EXTRA_LANGUAGE), results);
			}
			@Override
			public void onRmsChanged(float rmsdB) {
				mButtonMicrophone.setVolumeLevel(rmsdB);
			}
		});
		mButtonMicrophone.setOnTouchListener(new View.OnTouchListener() {
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				if (event.getAction() == MotionEvent.ACTION_DOWN) {
					vibrate();
				}
				return false;
			}
		});
		mButtonMicrophone.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				if (mState == State.INIT || mState == State.ERROR) {
					if (mTts != null) {
						mTts.stop();
					}
					if (audioCue != null) {
						audioCue.playStartSoundAndSleep();
					}
					sr.startListening(intentRecognizer);
				}
				else if (mState == State.RECORDING) {
				}
				else if (mState == State.TRANSCRIBING) {
				}
				else if (mState == State.LISTENING) {
					sr.stopListening();
				} else {
				}
			}
		});
		LinearLayout llMicrophone = (LinearLayout) findViewById(R.id.llMicrophone);
		llMicrophone.setVisibility(View.VISIBLE);
		llMicrophone.setEnabled(true);
	}
