Example usage for android.speech SpeechRecognizer ERROR_INSUFFICIENT_PERMISSIONS

List of usage examples for android.speech SpeechRecognizer ERROR_INSUFFICIENT_PERMISSIONS

Introduction

In this page you can find the example usage for android.speech SpeechRecognizer ERROR_INSUFFICIENT_PERMISSIONS.

Prototype

int ERROR_INSUFFICIENT_PERMISSIONS

To view the source code for android.speech SpeechRecognizer ERROR_INSUFFICIENT_PERMISSIONS.

Click Source Link

Document

Insufficient permissions

Usage

From source file:com.chexiaoya.gaodemapdemo.SpeechSearchActivity.java

@Override
public void onError(int error) {
    status = STATUS_None;/*ww w  .j  av  a  2s  . c o m*/
    StringBuilder sb = new StringBuilder();
    switch (error) {
    case SpeechRecognizer.ERROR_AUDIO:
        sb.append("");
        break;
    case SpeechRecognizer.ERROR_SPEECH_TIMEOUT:
        sb.append("");
        break;
    case SpeechRecognizer.ERROR_CLIENT:
        sb.append("");
        break;
    case SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS:
        sb.append("???");
        break;
    case SpeechRecognizer.ERROR_NETWORK:
        sb.append("");
        break;
    case SpeechRecognizer.ERROR_NO_MATCH:
        sb.append("?");
        break;
    case SpeechRecognizer.ERROR_RECOGNIZER_BUSY:
        sb.append("");
        break;
    case SpeechRecognizer.ERROR_SERVER:
        sb.append("?");
        break;
    case SpeechRecognizer.ERROR_NETWORK_TIMEOUT:
        sb.append("");
        break;
    }
    sb.append(":" + error);
    showToast(sb.toString());
}

From source file:com.baidu.android.voicedemo.ActivityTouch.java

@Override
public void onError(int error) {
    StringBuilder sb = new StringBuilder();
    switch (error) {
    case SpeechRecognizer.ERROR_AUDIO:
        sb.append("");
        break;/* w ww . jav a  2 s. c  o m*/
    case SpeechRecognizer.ERROR_SPEECH_TIMEOUT:
        sb.append("");
        break;
    case SpeechRecognizer.ERROR_CLIENT:
        sb.append("");
        break;
    case SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS:
        sb.append("???");
        break;
    case SpeechRecognizer.ERROR_NETWORK:
        sb.append("");
        break;
    case SpeechRecognizer.ERROR_NO_MATCH:
        sb.append("?");
        break;
    case SpeechRecognizer.ERROR_RECOGNIZER_BUSY:
        sb.append("");
        break;
    case SpeechRecognizer.ERROR_SERVER:
        sb.append("?");
        break;
    case SpeechRecognizer.ERROR_NETWORK_TIMEOUT:
        sb.append("");
        break;
    }
    sb.append(":" + error);
    print("" + sb.toString());
}

From source file:conversandroid.MainActivity.java

/**
 * Provides feedback to the user when the ASR encounters an error
 *//*from  ww w  .  j  a v a2 s  .c om*/
@Override
public void processAsrError(int errorCode) {
    changeButtonAppearanceToDefault();

    //Possible bug in Android SpeechRecognizer: NO_MATCH errors even before the the ASR
    // has even tried to recognized. We have adopted the solution proposed in:
    // http://stackoverflow.com/questions/31071650/speechrecognizer-throws-onerror-on-the-first-listening
    long duration = System.currentTimeMillis() - startListeningTime;
    if (duration < 500 && errorCode == SpeechRecognizer.ERROR_NO_MATCH) {
        Log.e(LOGTAG, "Doesn't seem like the system tried to listen at all. duration = " + duration
                + "ms. Going to ignore the error");
        stopListening();
    } else {
        String errorMsg = "";
        switch (errorCode) {
        case SpeechRecognizer.ERROR_AUDIO:
            errorMsg = "Audio recording error";
        case SpeechRecognizer.ERROR_CLIENT:
            errorMsg = "Unknown client side error";
        case SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS:
            errorMsg = "Insufficient permissions";
        case SpeechRecognizer.ERROR_NETWORK:
            errorMsg = "Network related error";
        case SpeechRecognizer.ERROR_NETWORK_TIMEOUT:
            errorMsg = "Network operation timed out";
        case SpeechRecognizer.ERROR_NO_MATCH:
            errorMsg = "No recognition result matched";
        case SpeechRecognizer.ERROR_RECOGNIZER_BUSY:
            errorMsg = "RecognitionService busy";
        case SpeechRecognizer.ERROR_SERVER:
            errorMsg = "Server sends error status";
        case SpeechRecognizer.ERROR_SPEECH_TIMEOUT:
            errorMsg = "No speech input";
        default:
            errorMsg = ""; //Another frequent error that is not really due to the ASR, we will ignore it
        }
        if (errorMsg != "") {
            Log.e(LOGTAG, "Error when attempting to listen: " + errorMsg);

            try {
                speak(errorMsg, "EN", ID_PROMPT_INFO);
            } catch (Exception e) {
                Log.e(LOGTAG, "English not available for TTS, default language used instead");
            }
        }
    }

}

From source file:com.baidu.android.voicedemo.ApiActivity.java

@Override
public void onError(int error) {
    status = STATUS_None;/*  w  ww.  j a  v a2  s.  co m*/
    StringBuilder sb = new StringBuilder();
    switch (error) {
    case SpeechRecognizer.ERROR_AUDIO:
        sb.append("");
        break;
    case SpeechRecognizer.ERROR_SPEECH_TIMEOUT:
        sb.append("");
        break;
    case SpeechRecognizer.ERROR_CLIENT:
        sb.append("");
        break;
    case SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS:
        sb.append("???");
        break;
    case SpeechRecognizer.ERROR_NETWORK:
        sb.append("");
        break;
    case SpeechRecognizer.ERROR_NO_MATCH:
        sb.append("?");
        break;
    case SpeechRecognizer.ERROR_RECOGNIZER_BUSY:
        sb.append("");
        break;
    case SpeechRecognizer.ERROR_SERVER:
        sb.append("?");
        break;
    case SpeechRecognizer.ERROR_NETWORK_TIMEOUT:
        sb.append("");
        break;
    }
    sb.append(":" + error);
    print("" + sb.toString());
    btn.setText("");
}

From source file:cn.laojing.smarthome.VoiceActivity.java

@Override
public void onError(int error) {
    StringBuilder sb = new StringBuilder();
    switch (error) {
    case SpeechRecognizer.ERROR_AUDIO:
        sb.append("");
        break;//from w ww. j  a  va2s  .  com
    case SpeechRecognizer.ERROR_SPEECH_TIMEOUT:
        sb.append("");
        break;
    case SpeechRecognizer.ERROR_CLIENT:
        sb.append("");
        break;
    case SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS:
        sb.append("???");
        break;
    case SpeechRecognizer.ERROR_NETWORK:
        sb.append("");
        break;
    case SpeechRecognizer.ERROR_NO_MATCH:
        sb.append("?");
        break;
    case SpeechRecognizer.ERROR_RECOGNIZER_BUSY:
        sb.append("");
        break;
    case SpeechRecognizer.ERROR_SERVER:
        sb.append("?");
        break;
    case SpeechRecognizer.ERROR_NETWORK_TIMEOUT:
        sb.append("");
        break;
    }
    sb.append(":" + error);
    print("" + sb.toString());
    start();
}

From source file:conversandroid.RichASR.java

@Override
public void onError(final int errorCode) {

    //Possible bug in Android SpeechRecognizer: NO_MATCH errors even before the the ASR
    // has even tried to recognized. We have adopted the solution proposed in:
    // http://stackoverflow.com/questions/31071650/speechrecognizer-throws-onerror-on-the-first-listening
    long duration = System.currentTimeMillis() - startListeningTime;
    if (duration < 500 && errorCode == SpeechRecognizer.ERROR_NO_MATCH) {
        Log.e(LOGTAG, "Doesn't seem like the system tried to listen at all. duration = " + duration
                + "ms. Going to ignore the error");
        stopListening();/*from  ww w.j  a v a2s.co  m*/
    } else {
        String errorMsg = "";
        switch (errorCode) {
        case SpeechRecognizer.ERROR_AUDIO:
            errorMsg = "Audio recording error";
        case SpeechRecognizer.ERROR_CLIENT:
            errorMsg = "Unknown client side error";
        case SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS:
            errorMsg = "Insufficient permissions";
        case SpeechRecognizer.ERROR_NETWORK:
            errorMsg = "Network related error";
        case SpeechRecognizer.ERROR_NETWORK_TIMEOUT:
            errorMsg = "Network operation timed out";
        case SpeechRecognizer.ERROR_NO_MATCH:
            errorMsg = "No recognition result matched";
        case SpeechRecognizer.ERROR_RECOGNIZER_BUSY:
            errorMsg = "RecognitionService busy";
        case SpeechRecognizer.ERROR_SERVER:
            errorMsg = "Server sends error status";
        case SpeechRecognizer.ERROR_SPEECH_TIMEOUT:
            errorMsg = "No speech input";
        default:
            errorMsg = "";
        }
        if (errorCode == 5 && errorMsg == "") {
            //Log.e(LOGTAG, "Going to ignore the error");
            //Another frequent error that is not really due to the ASR
        } else {
            ((TextView) findViewById(R.id.feedbackTxt)).setText("Error :( " + errorMsg);
            Log.e(LOGTAG, "Error -> " + errorMsg);
            stopListening();
        }
    }
}

From source file:cn.jasonlv.siri.activity.MainActivity.java

@Override
public void onError(int error) {
    status = STATUS_None;//  w ww  . j  av  a2  s.c  om
    StringBuilder sb = new StringBuilder();
    switch (error) {
    case SpeechRecognizer.ERROR_AUDIO:
        sb.append("");
        break;
    case SpeechRecognizer.ERROR_SPEECH_TIMEOUT:
        sb.append("");
        break;
    case SpeechRecognizer.ERROR_CLIENT:
        sb.append("");
        break;
    case SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS:
        sb.append("???");
        break;
    case SpeechRecognizer.ERROR_NETWORK:
        sb.append("");
        break;
    case SpeechRecognizer.ERROR_NO_MATCH:
        sb.append("?");
        break;
    case SpeechRecognizer.ERROR_RECOGNIZER_BUSY:
        sb.append("");
        break;
    case SpeechRecognizer.ERROR_SERVER:
        sb.append("?");
        break;
    case SpeechRecognizer.ERROR_NETWORK_TIMEOUT:
        sb.append("");
        break;
    }
    sb.append(":" + error);
    print("" + sb.toString());
    //btn.setText("");
}

From source file:com.glabs.homegenie.util.VoiceControl.java

@Override
public void onError(int i) {
    String message;/*from   w  w  w.j  av  a2  s.c  o m*/
    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, 10000).show();
    _recognizer.destroy();
    _recognizer = null;
}

From source file:org.botlibre.sdk.activity.MicConfiguration.java

@Override
public void onError(int error) {
    isRecording = false;// w w  w  .  j  ava  2 s. co  m

    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();
    }

}

From source file:com.vyasware.vaani.MainActivity.java

public static String getErrorText(int errorCode) {
    String message;/*from   w w  w  . j  a v a  2s .  c  o m*/
    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;
}