Java Code Examples for android.speech.SpeechRecognizer#ERROR_CLIENT

The following examples show how to use android.speech.SpeechRecognizer#ERROR_CLIENT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ErrorTranslation.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
public static String recogError(int errorCode) {
    String message;
    switch (errorCode) {
        case SpeechRecognizer.ERROR_AUDIO:
            message = "音频问题";
            break;
        case SpeechRecognizer.ERROR_SPEECH_TIMEOUT:
            message = "没有语音输入";
            break;
        case SpeechRecognizer.ERROR_CLIENT:
            message = "其它客户端错误";
            break;
        case SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS:
            message = "权限不足";
            break;
        case SpeechRecognizer.ERROR_NETWORK:
            message = "网络问题";
            break;
        case SpeechRecognizer.ERROR_NO_MATCH:
            message = "没有匹配的识别结果";
            break;
        case SpeechRecognizer.ERROR_RECOGNIZER_BUSY:
            message = "引擎忙";
            break;
        case SpeechRecognizer.ERROR_SERVER:
            message = "服务端错误";
            break;
        case SpeechRecognizer.ERROR_NETWORK_TIMEOUT:
            message = "连接超时";
            break;
        default:
            message = "未知错误:" + errorCode;
            break;
    }
    return message;
}
 
Example 2
Source File: ServiceBasedSpeechRecognizer.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
private int getErrorMessage(int errorCode) {
  int errCode = ErrorMessages.ERROR_DEFAULT;
  switch (errorCode) {
    case SpeechRecognizer.ERROR_AUDIO:
      errCode = ErrorMessages.ERROR_AUDIO;
      break;
    case SpeechRecognizer.ERROR_CLIENT:
      errCode = ErrorMessages.ERROR_CLIENT;
      break;
    case SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS:
      errCode = ErrorMessages.ERROR_INSUFFICIENT_PERMISSIONS;
      break;
    case SpeechRecognizer.ERROR_NETWORK:
      errCode = ErrorMessages.ERROR_NETWORK;
      break;
    case SpeechRecognizer.ERROR_NETWORK_TIMEOUT:
      errCode = ErrorMessages.ERROR_NETWORK_TIMEOUT;
      break;
    case SpeechRecognizer.ERROR_NO_MATCH:
      errCode = ErrorMessages.ERROR_NO_MATCH;
      break;
    case SpeechRecognizer.ERROR_RECOGNIZER_BUSY:
      errCode = ErrorMessages.ERROR_RECOGNIZER_BUSY;
      break;
    case SpeechRecognizer.ERROR_SERVER:
      errCode = ErrorMessages.ERROR_SERVER;
      break;
    case SpeechRecognizer.ERROR_SPEECH_TIMEOUT:
      errCode = ErrorMessages.ERROR_SPEECH_TIMEOUT;
      break;
  }
  return errCode;
}
 
Example 3
Source File: SpeechRecognition.java    From cordova-plugin-speechrecognition with MIT License 5 votes vote down vote up
private String getErrorText(int errorCode) {
  String message;
  switch (errorCode) {
    case SpeechRecognizer.ERROR_AUDIO:
      message = "Audio recording error";
      break;
    case SpeechRecognizer.ERROR_CLIENT:
      message = "Client side error";
      break;
    case SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS:
      message = "Insufficient permissions";
      break;
    case SpeechRecognizer.ERROR_NETWORK:
      message = "Network error";
      break;
    case SpeechRecognizer.ERROR_NETWORK_TIMEOUT:
      message = "Network timeout";
      break;
    case SpeechRecognizer.ERROR_NO_MATCH:
      message = "No match";
      break;
    case SpeechRecognizer.ERROR_RECOGNIZER_BUSY:
      message = "RecognitionService busy";
      break;
    case SpeechRecognizer.ERROR_SERVER:
      message = "error from server";
      break;
    case SpeechRecognizer.ERROR_SPEECH_TIMEOUT:
      message = "No speech input";
      break;
    default:
      message = "Didn't understand, please try again.";
      break;
  }
  return message;
}
 
Example 4
Source File: SpeechRecognitionListener.java    From Android-Speech-Recognition with MIT License 4 votes vote down vote up
@Override
public void onError(int i) {

    String errorMessage = "";
    int errorCode = -1;

    switch (i) {
        case SpeechRecognizer.ERROR_AUDIO:
            errorCode = SpeechRecognizer.ERROR_AUDIO;
            errorMessage = context.getString(R.string.error_audio);
            break;

        case SpeechRecognizer.ERROR_CLIENT:
            errorCode = SpeechRecognizer.ERROR_CLIENT;
            errorMessage = context.getString(R.string.error_client);
            break;

        case SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS:
            errorCode = SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS;
            errorMessage = context.getString(R.string.error_permission);
            break;

        case SpeechRecognizer.ERROR_NETWORK:
            errorCode = SpeechRecognizer.ERROR_NETWORK;
            errorMessage = context.getString(R.string.error_network);
            break;

        case SpeechRecognizer.ERROR_NETWORK_TIMEOUT:
            errorCode = SpeechRecognizer.ERROR_NETWORK_TIMEOUT;
            errorMessage = context.getString(R.string.error_network);
            break;

        case SpeechRecognizer.ERROR_NO_MATCH:
            errorCode = SpeechRecognizer.ERROR_NO_MATCH;
            errorMessage = context.getString(R.string.error_no_match);
            break;

        case SpeechRecognizer.ERROR_RECOGNIZER_BUSY:
            errorCode = SpeechRecognizer.ERROR_RECOGNIZER_BUSY;
            errorMessage = context.getString(R.string.error_recognizer_busy);
            break;

        case SpeechRecognizer.ERROR_SERVER:
            errorCode = SpeechRecognizer.ERROR_SERVER;
            errorMessage = context.getString(R.string.error_server);
            break;

        case SpeechRecognizer.ERROR_SPEECH_TIMEOUT:
            errorCode = SpeechRecognizer.ERROR_SPEECH_TIMEOUT;
            errorMessage = context.getString(R.string.error_no_input);
            break;

        default:
            errorMessage = context.getString(R.string.error_undefined);
            break;
    }

    onSpeechRecognitionListener.OnSpeechRecognitionError(errorCode, errorMessage);
}
 
Example 5
Source File: SpeechRecognitionException.java    From android-speech with Apache License 2.0 4 votes vote down vote up
private static String getMessage(int code) {
    String message;

    // these have been mapped from here:
    // https://developer.android.com/reference/android/speech/SpeechRecognizer.html
    switch(code) {
        case SpeechRecognizer.ERROR_AUDIO:
            message = code + " - Audio recording error";
            break;

        case SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS:
            message = code + " - Insufficient permissions. Request android.permission.RECORD_AUDIO";
            break;

        case SpeechRecognizer.ERROR_CLIENT:
            // http://stackoverflow.com/questions/24995565/android-speechrecognizer-when-do-i-get-error-client-when-starting-the-voice-reco
            message = code + " - Client side error. Maybe your internet connection is poor!";
            break;

        case SpeechRecognizer.ERROR_NETWORK:
            message = code + " - Network error";
            break;

        case SpeechRecognizer.ERROR_NETWORK_TIMEOUT:
            message = code + " - Network operation timed out";
            break;

        case SpeechRecognizer.ERROR_NO_MATCH:
            message = code + " - No recognition result matched. Try turning on partial results as a workaround.";
            break;

        case SpeechRecognizer.ERROR_RECOGNIZER_BUSY:
            message = code + " - RecognitionService busy";
            break;

        case SpeechRecognizer.ERROR_SERVER:
            message = code + " - Server sends error status";
            break;

        case SpeechRecognizer.ERROR_SPEECH_TIMEOUT:
            message = code + " - No speech input";
            break;

        default:
            message = code + " - Unknown exception";
            break;
    }

    return message;
}
 
Example 6
Source File: MainActivity.java    From iqra-android with MIT License 4 votes vote down vote up
@Override
public void onError(int error) {
    String mError = "";
    switch (error) {
        case SpeechRecognizer.ERROR_NETWORK_TIMEOUT:
            mError = getResources().getString(R.string.error_network_timeout);
            mSpeechRecognizer.startListening(mSpeechRecognizerIntent);
            break;
        case SpeechRecognizer.ERROR_NETWORK:
            mError = getResources().getString(R.string.error_network);
            mSpeechRecognizer.cancel();
            mIsListening = false;
            recordCircle.setImageResource(R.drawable.record_circle_inactive);
            break;
        case SpeechRecognizer.ERROR_AUDIO:
            mError = getResources().getString(R.string.error_audio);
            mSpeechRecognizer.startListening(mSpeechRecognizerIntent);
            break;
        case SpeechRecognizer.ERROR_SERVER:
            mError = getResources().getString(R.string.error_server);
            mSpeechRecognizer.startListening(mSpeechRecognizerIntent);
            break;
        case SpeechRecognizer.ERROR_CLIENT:
            mError = getResources().getString(R.string.error_client);
            mSpeechRecognizer.startListening(mSpeechRecognizerIntent);
            break;
        case SpeechRecognizer.ERROR_SPEECH_TIMEOUT:
            mError = getResources().getString(R.string.error_speech_timeout);
            mSpeechRecognizer.startListening(mSpeechRecognizerIntent);
            break;
        case SpeechRecognizer.ERROR_NO_MATCH:
            mError = getResources().getString(R.string.error_no_match);
            mSpeechRecognizer.startListening(mSpeechRecognizerIntent);
            break;
        case SpeechRecognizer.ERROR_RECOGNIZER_BUSY:
            mError = getResources().getString(R.string.error_recognizer_busy);
            mSpeechRecognizer.cancel();
            mIsListening = false;
            recordCircle.setImageResource(R.drawable.record_circle_inactive);
            break;
        case SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS:
            mError = getResources().getString(R.string.error_insufficient_permissions);
            mSpeechRecognizer.cancel();
            mIsListening = false;
            recordCircle.setImageResource(R.drawable.record_circle_inactive);
            break;
    }
    Log.i(TAG, "Error: " + error + " - " + mError);

    micText.setText(mError);
    recordCircle.getLayoutParams().width = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 80, getResources().getDisplayMetrics());
    recordCircle.getLayoutParams().height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 80, getResources().getDisplayMetrics());
    recordCircle.requestLayout();
    partialResult.setText("");
}
 
Example 7
Source File: MicConfiguration.java    From BotLibre with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void onError(int error) {
	isRecording = false;

	lastReply = System.currentTimeMillis();
	
	this.speech.destroy();
	this.speech = SpeechRecognizer.createSpeechRecognizer(this);
	this.speech.setRecognitionListener(this);

	setMicIcon(false, false);

	muteMicBeep(false);

	setStreamVolume();
	
	if (error == SpeechRecognizer.ERROR_AUDIO) {
		Log.d("System.out", "Error: Audio Recording Error");
	} else if (error == SpeechRecognizer.ERROR_CLIENT) {
		Log.d("System.out", "Error: Other client side error");
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS) {
		Log.d("System.out", "Error: INsufficient permissions");
	} else if (error == SpeechRecognizer.ERROR_NETWORK) {
		Log.d("System.out", "Error: Other network Error");
	} else if (error == SpeechRecognizer.ERROR_NETWORK_TIMEOUT) {
		Log.d("System.out", "Error: Network operation timed out");
	} else if (error == SpeechRecognizer.ERROR_NO_MATCH) {
		Log.d("System.out", "Error: No recognition result matched");
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_RECOGNIZER_BUSY) {
		Log.d("System.out", "Error: Recognition service busy");
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_SERVER) {
		Log.d("System.out", "Error: Server Error");
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_SPEECH_TIMEOUT) {
		Log.d("System.out", "Error: NO speech input");
		restartListening();
	}
	
}
 
Example 8
Source File: ChatActivity.java    From BotLibre with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void onError(int error) {
	debug("onError:" + error);
	Log.d("onError Info", "ChatActivity on error executes here!");
	try{
	isRecording = false;

	lastReply = System.currentTimeMillis();
	this.speech.destroy();
	this.speech = SpeechRecognizer.createSpeechRecognizer(this);
	this.speech.setRecognitionListener(this);
	
	setMicIcon(false, false);

	muteMicBeep(false);

	setStreamVolume();
	
	if (error == SpeechRecognizer.ERROR_AUDIO) {
		Log.d("System.out", "Error: Audio Recording Error");
	} else if (error == SpeechRecognizer.ERROR_CLIENT) {
		Log.d("System.out", "Error: Other client side error");
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS) {
		Log.d("System.out", "Error: INsufficient permissions");
	} else if (error == SpeechRecognizer.ERROR_NETWORK) {
		Log.d("System.out", "Error: Other network Error");
	} else if (error == SpeechRecognizer.ERROR_NETWORK_TIMEOUT) {
		Log.d("System.out", "Error: Network operation timed out");
	} else if (error == SpeechRecognizer.ERROR_NO_MATCH) {
		Log.d("System.out", "Error: No recognition result matched");
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_RECOGNIZER_BUSY) {
		Log.d("System.out", "Error: Recognition service busy");
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_SERVER) {
		Log.d("System.out", "Error: Server Error");
		failedOfflineLanguage = true;
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_SPEECH_TIMEOUT) {
		Log.d("System.out", "Error: NO speech input");
		isListening = true;
		restartListening();
	}
	}catch(Exception e){Log.e("micError",e.getMessage());}
}
 
Example 9
Source File: MicConfiguration.java    From BotLibre with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void onError(int error) {
	isRecording = false;

	lastReply = System.currentTimeMillis();
	
	this.speech.destroy();
	this.speech = SpeechRecognizer.createSpeechRecognizer(this);
	this.speech.setRecognitionListener(this);

	setMicIcon(false, false);

	muteMicBeep(false);

	setStreamVolume();
	
	if (error == SpeechRecognizer.ERROR_AUDIO) {
		Log.d("System.out", "Error: Audio Recording Error");
	} else if (error == SpeechRecognizer.ERROR_CLIENT) {
		Log.d("System.out", "Error: Other client side error");
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS) {
		Log.d("System.out", "Error: INsufficient permissions");
	} else if (error == SpeechRecognizer.ERROR_NETWORK) {
		Log.d("System.out", "Error: Other network Error");
	} else if (error == SpeechRecognizer.ERROR_NETWORK_TIMEOUT) {
		Log.d("System.out", "Error: Network operation timed out");
	} else if (error == SpeechRecognizer.ERROR_NO_MATCH) {
		Log.d("System.out", "Error: No recognition result matched");
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_RECOGNIZER_BUSY) {
		Log.d("System.out", "Error: Recognition service busy");
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_SERVER) {
		Log.d("System.out", "Error: Server Error");
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_SPEECH_TIMEOUT) {
		Log.d("System.out", "Error: NO speech input");
		restartListening();
	}
	
}
 
Example 10
Source File: ChatActivity.java    From BotLibre with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void onError(int error) {
	debug("onError:" + error);
	Log.d("onError Info", "ChatActivity on error executes here!");
	try{
	this.isRecording = false;

	this.lastReply = System.currentTimeMillis();
	this.speech.destroy();
	this.speech = SpeechRecognizer.createSpeechRecognizer(this);
	this.speech.setRecognitionListener(this);
	
	setMicIcon(false, false);

	muteMicBeep(false);

	setStreamVolume();
	
	if (error == SpeechRecognizer.ERROR_AUDIO) {
		Log.d("System.out", "Error: Audio Recording Error");
	} else if (error == SpeechRecognizer.ERROR_CLIENT) {
		Log.d("System.out", "Error: Other client side error");
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS) {
		Log.d("System.out", "Error: INsufficient permissions");
	} else if (error == SpeechRecognizer.ERROR_NETWORK) {
		Log.d("System.out", "Error: Other network Error");
	} else if (error == SpeechRecognizer.ERROR_NETWORK_TIMEOUT) {
		Log.d("System.out", "Error: Network operation timed out");
	} else if (error == SpeechRecognizer.ERROR_NO_MATCH) {
		Log.d("System.out", "Error: No recognition result matched");
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_RECOGNIZER_BUSY) {
		Log.d("System.out", "Error: Recognition service busy");
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_SERVER) {
		Log.d("System.out", "Error: Server Error");
		failedOfflineLanguage = true;
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_SPEECH_TIMEOUT) {
		Log.d("System.out", "Error: NO speech input");
		isListening = true;
		restartListening();
	}
	}catch(Exception e){Log.e("micError",e.getMessage());}
}
 
Example 11
Source File: MicConfiguration.java    From BotLibre with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void onError(int error) {
	isRecording = false;

	lastReply = System.currentTimeMillis();
	
	this.speech.destroy();
	this.speech = SpeechRecognizer.createSpeechRecognizer(this);
	this.speech.setRecognitionListener(this);

	setMicIcon(false, false);

	muteMicBeep(false);

	setStreamVolume();
	
	if (error == SpeechRecognizer.ERROR_AUDIO) {
		Log.d("System.out", "Error: Audio Recording Error");
	} else if (error == SpeechRecognizer.ERROR_CLIENT) {
		Log.d("System.out", "Error: Other client side error");
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS) {
		Log.d("System.out", "Error: INsufficient permissions");
	} else if (error == SpeechRecognizer.ERROR_NETWORK) {
		Log.d("System.out", "Error: Other network Error");
	} else if (error == SpeechRecognizer.ERROR_NETWORK_TIMEOUT) {
		Log.d("System.out", "Error: Network operation timed out");
	} else if (error == SpeechRecognizer.ERROR_NO_MATCH) {
		Log.d("System.out", "Error: No recognition result matched");
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_RECOGNIZER_BUSY) {
		Log.d("System.out", "Error: Recognition service busy");
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_SERVER) {
		Log.d("System.out", "Error: Server Error");
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_SPEECH_TIMEOUT) {
		Log.d("System.out", "Error: NO speech input");
		restartListening();
	}
	
}
 
Example 12
Source File: ChatActivity.java    From BotLibre with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void onError(int error) {
	debug("onError:" + error);
	Log.d("onError Info", "ChatActivity on error executes here!");
	try{
	this.isRecording = false;

	this.lastReply = System.currentTimeMillis();
	this.speech.destroy();
	this.speech = SpeechRecognizer.createSpeechRecognizer(this);
	this.speech.setRecognitionListener(this);
	
	setMicIcon(false, false);

	muteMicBeep(false);

	setStreamVolume();
	
	if (error == SpeechRecognizer.ERROR_AUDIO) {
		Log.d("System.out", "Error: Audio Recording Error");
	} else if (error == SpeechRecognizer.ERROR_CLIENT) {
		Log.d("System.out", "Error: Other client side error");
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS) {
		Log.d("System.out", "Error: INsufficient permissions");
	} else if (error == SpeechRecognizer.ERROR_NETWORK) {
		Log.d("System.out", "Error: Other network Error");
	} else if (error == SpeechRecognizer.ERROR_NETWORK_TIMEOUT) {
		Log.d("System.out", "Error: Network operation timed out");
	} else if (error == SpeechRecognizer.ERROR_NO_MATCH) {
		Log.d("System.out", "Error: No recognition result matched");
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_RECOGNIZER_BUSY) {
		Log.d("System.out", "Error: Recognition service busy");
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_SERVER) {
		Log.d("System.out", "Error: Server Error");
		failedOfflineLanguage = true;
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_SPEECH_TIMEOUT) {
		Log.d("System.out", "Error: NO speech input");
		isListening = true;
		restartListening();
	}
	}catch(Exception e){Log.e("micError",e.getMessage());}
}
 
Example 13
Source File: MicConfiguration.java    From BotLibre with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void onError(int error) {
	isRecording = false;

	lastReply = System.currentTimeMillis();
	
	this.speech.destroy();
	this.speech = SpeechRecognizer.createSpeechRecognizer(this);
	this.speech.setRecognitionListener(this);

	setMicIcon(false, false);

	muteMicBeep(false);

	setStreamVolume();
	
	if (error == SpeechRecognizer.ERROR_AUDIO) {
		Log.d("System.out", "Error: Audio Recording Error");
	} else if (error == SpeechRecognizer.ERROR_CLIENT) {
		Log.d("System.out", "Error: Other client side error");
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS) {
		Log.d("System.out", "Error: INsufficient permissions");
	} else if (error == SpeechRecognizer.ERROR_NETWORK) {
		Log.d("System.out", "Error: Other network Error");
	} else if (error == SpeechRecognizer.ERROR_NETWORK_TIMEOUT) {
		Log.d("System.out", "Error: Network operation timed out");
	} else if (error == SpeechRecognizer.ERROR_NO_MATCH) {
		Log.d("System.out", "Error: No recognition result matched");
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_RECOGNIZER_BUSY) {
		Log.d("System.out", "Error: Recognition service busy");
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_SERVER) {
		Log.d("System.out", "Error: Server Error");
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_SPEECH_TIMEOUT) {
		Log.d("System.out", "Error: NO speech input");
		restartListening();
	}
	
}
 
Example 14
Source File: ChatActivity.java    From BotLibre with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void onError(int error) {
	debug("onError:" + error);
	Log.d("onError Info", "ChatActivity on error executes here!");
	try{
	isRecording = false;

	lastReply = System.currentTimeMillis();
	this.speech.destroy();
	this.speech = SpeechRecognizer.createSpeechRecognizer(this);
	this.speech.setRecognitionListener(this);
	
	setMicIcon(false, false);

	muteMicBeep(false);

	setStreamVolume();
	
	if (error == SpeechRecognizer.ERROR_AUDIO) {
		Log.d("System.out", "Error: Audio Recording Error");
	} else if (error == SpeechRecognizer.ERROR_CLIENT) {
		Log.d("System.out", "Error: Other client side error");
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS) {
		Log.d("System.out", "Error: INsufficient permissions");
	} else if (error == SpeechRecognizer.ERROR_NETWORK) {
		Log.d("System.out", "Error: Other network Error");
	} else if (error == SpeechRecognizer.ERROR_NETWORK_TIMEOUT) {
		Log.d("System.out", "Error: Network operation timed out");
	} else if (error == SpeechRecognizer.ERROR_NO_MATCH) {
		Log.d("System.out", "Error: No recognition result matched");
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_RECOGNIZER_BUSY) {
		Log.d("System.out", "Error: Recognition service busy");
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_SERVER) {
		Log.d("System.out", "Error: Server Error");
		failedOfflineLanguage = true;
		restartListening();
	} else if (error == SpeechRecognizer.ERROR_SPEECH_TIMEOUT) {
		Log.d("System.out", "Error: NO speech input");
		isListening = true;
		restartListening();
	}
	}catch(Exception e){Log.e("micError",e.getMessage());}
}
 
Example 15
Source File: VoiceControl.java    From HomeGenie-Android with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onError(int i) {
    String message;
    switch (i) {
        case SpeechRecognizer.ERROR_AUDIO:
            message = "Audio recording error";
            break;
        case SpeechRecognizer.ERROR_CLIENT:
            message = "Client side error";
            //restart = false;
            break;
        case SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS:
            message = "Insufficient permissions";
            //restart = false;
            break;
        case SpeechRecognizer.ERROR_NETWORK:
            message = "Network error";
            break;
        case SpeechRecognizer.ERROR_NETWORK_TIMEOUT:
            message = "Network timeout";
            break;
        case SpeechRecognizer.ERROR_NO_MATCH:
            message = "No match";
            break;
        case SpeechRecognizer.ERROR_RECOGNIZER_BUSY:
            message = "RecognitionService busy";
            break;
        case SpeechRecognizer.ERROR_SERVER:
            message = "error from server";
            break;
        case SpeechRecognizer.ERROR_SPEECH_TIMEOUT:
            message = "No speech input";
            break;
        default:
            message = "Not recognised";
            break;
    }
    Toast.makeText(_hgcontext.getApplicationContext(), "Recognizer: " + message, Toast.LENGTH_SHORT).show();
    if (_recognizer != null) {
        _recognizer.destroy();
        _recognizer = null;
    }
}