List of usage examples for android.speech SpeechRecognizer ERROR_NETWORK
int ERROR_NETWORK
To view the source code for android.speech SpeechRecognizer ERROR_NETWORK.
Click Source Link
From source file:com.chexiaoya.gaodemapdemo.SpeechSearchActivity.java
@Override public void onError(int error) { status = STATUS_None;//from w w w . j av a 2 s .com 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;// www . jav a 2 s. co 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 www . j a v a2s .c o m*/ @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;//ww w.j a v a2s.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: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 w w . java2 s . c om 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();// w ww. ja v a 2 s . 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:com.todoroo.astrid.activity.AstridActivity.java
@Override public void onSpeechError(int error) { TaskListFragment tlf = getTaskListFragment(); if (tlf != null) { QuickAddBar quickAdd = tlf.quickAddBar; if (quickAdd != null) { VoiceRecognizer vr = quickAdd.getVoiceRecognizer(); if (vr != null) vr.cancel();/*from ww w . j ava 2 s . co m*/ } } int errorStr = 0; switch (error) { case SpeechRecognizer.ERROR_NETWORK: case SpeechRecognizer.ERROR_NETWORK_TIMEOUT: errorStr = R.string.speech_err_network; break; case SpeechRecognizer.ERROR_NO_MATCH: Toast.makeText(this, R.string.speech_err_no_match, Toast.LENGTH_LONG).show(); break; default: errorStr = R.string.speech_err_default; break; } if (errorStr > 0) DialogUtilities.okDialog(this, getString(errorStr), null); }
From source file:cn.jasonlv.siri.activity.MainActivity.java
@Override public void onError(int error) { status = STATUS_None;/*from w ww . ja v a2s. com*/ 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 www . j ava 2s. com*/ 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;/*from w w w.j a v a 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(); } }