List of usage examples for android.speech.tts TextToSpeech SUCCESS
int SUCCESS
To view the source code for android.speech.tts TextToSpeech SUCCESS.
Click Source Link
From source file:com.jtxdriggers.android.ventriloid.VentriloidService.java
@Override public void onCreate() { stopForeground(true);//from www .j a v a 2s . c o m new Thread(new Runnable() { @Override public void run() { Looper.prepare(); handler = new Handler(); Looper.loop(); } }).start(); items = new ItemData(this); player = new Player(this); recorder = new Recorder(this); prefs = PreferenceManager.getDefaultSharedPreferences(this); if (prefs.getString("notification_type", "Text to Speech").equals("Text to Speech")) { ttsActive = true; tts = new TextToSpeech(VentriloidService.this, new TextToSpeech.OnInitListener() { @Override public void onInit(int status) { if (status == TextToSpeech.SUCCESS) ttsActive = true; else { ttsActive = false; handler.post(new Runnable() { @Override public void run() { Toast.makeText(getApplicationContext(), "TTS Initialization faled.", Toast.LENGTH_SHORT).show(); } }); } } }); } else if (prefs.getString("notification_type", "Text to Speech").equals("Ringtone")) ringtoneActive = true; registerReceiver(activityReceiver, new IntentFilter(ACTIVITY_RECEIVER)); nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE); am = (AudioManager) getSystemService(Context.AUDIO_SERVICE); voiceActivation = prefs.getBoolean("voice_activation", false); threshold = voiceActivation ? 55.03125 : -1; vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); vibrate = prefs.getBoolean("vibrate", true); queue = new ConcurrentLinkedQueue<VentriloEventData>(); //VentriloInterface.debuglevel(65535); new Thread(eventHandler).start(); }
From source file:in.rade.armud.armudclient.MainActivity.java
@Override public void onInit(int code) { if (code == TextToSpeech.SUCCESS) { tts.setLanguage(Locale.getDefault()); Log.d("TTS initialised. Code: ", String.valueOf(code)); } else {//from w w w.j a v a2 s . com tts = null; Log.d("TTS failed. Code:", String.valueOf(code)); } }
From source file:com.eng.arab.translator.androidtranslator.ShowDetailsMonth.java
public void onInit(int initStatus) { //check for successful instantiation if (initStatus == TextToSpeech.SUCCESS) { if (myTTS.isLanguageAvailable(Locale.US) == TextToSpeech.LANG_AVAILABLE) myTTS.setLanguage(Locale.US); } else if (initStatus == TextToSpeech.ERROR) { Toast.makeText(getApplicationContext(), "Sorry! Text To Speech failed...", Toast.LENGTH_LONG).show(); }//from w w w.j a v a 2s . co m }
From source file:com.phonegap.plugins.speech.TTS.java
/** * Called when the TTS service is initialized. * * @param status/* www . j a v a 2 s . c o m*/ */ public void onInit(int status) { if (status == TextToSpeech.SUCCESS) { state = TTS.STARTED; PluginResult result = new PluginResult(PluginResult.Status.OK, TTS.STARTED); result.setKeepCallback(false); //this.success(result, this.startupCallbackId); this.startupCallbackContext.sendPluginResult(result); mTts.setOnUtteranceCompletedListener(this); // Putting this code in hear as a place holder. When everything moves to API level 15 or greater // we'll switch over to this way of trackign progress. // mTts.setOnUtteranceProgressListener(new UtteranceProgressListener() { // // @Override // public void onDone(String utteranceId) { // Log.d(LOG_TAG, "got completed utterance"); // PluginResult result = new PluginResult(PluginResult.Status.OK); // result.setKeepCallback(false); // callbackContext.sendPluginResult(result); // } // // @Override // public void onError(String utteranceId) { // Log.d(LOG_TAG, "got utterance error"); // PluginResult result = new PluginResult(PluginResult.Status.ERROR); // result.setKeepCallback(false); // callbackContext.sendPluginResult(result); // } // // @Override // public void onStart(String utteranceId) { // Log.d(LOG_TAG, "started talking"); // } // // }); } else if (status == TextToSpeech.ERROR) { state = TTS.STOPPED; PluginResult result = new PluginResult(PluginResult.Status.ERROR, TTS.STOPPED); result.setKeepCallback(false); this.startupCallbackContext.sendPluginResult(result); } }
From source file:org.apache.cordova.plugins.speech.TTS.java
/** * Called when the TTS service is initialized. * * @param status/*from w ww . ja v a 2 s . c o m*/ */ public void onInit(int status) { if (status == TextToSpeech.SUCCESS) { Log.d(LOG_TAG, "TextToSpeech init succeeded"); state = TTS.STARTED; PluginResult result = new PluginResult(PluginResult.Status.OK, TTS.STARTED); result.setKeepCallback(false); this.callbackContext.sendPluginResult(result); // Default Lang US mTts.setLanguage(Locale.US); if (Build.VERSION.SDK_INT >= 15) { mTts.setOnUtteranceProgressListener(new TTSProgressListener(this.callbackContext)); } else { mTts.setOnUtteranceCompletedListener(new TTSCompletedListener(this.callbackContext)); } } else if (status == TextToSpeech.ERROR) { Log.d(LOG_TAG, "TextToSpeech init error"); state = TTS.STOPPED; PluginResult result = new PluginResult(PluginResult.Status.ERROR, TTS.STOPPED); result.setKeepCallback(false); this.callbackContext.sendPluginResult(result); } }
From source file:com.example.h156252.connected_cars.CarGrid.java
@Override public void onInit(int status) { if (status == TextToSpeech.SUCCESS) { int result = tts.setLanguage(Locale.US); if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) { Log.e("TTS", "This Language is not supported"); } else {/*ww w. j av a 2 s . c om*/ /*btnSpeak.setEnabled(true); speakOut();*/ } } else { Log.e("TTS", "Initilization Failed!"); } }
From source file:com.firerunner.cordova.TTS.java
/** * Called when the TTS service is initialized. * * @param status/*from w w w .j a v a 2s . c om*/ */ public void onInit(int status) { if (status == TextToSpeech.SUCCESS) { state = TTS.STARTED; //Voice v = mTts.getVoice(); //v. PluginResult result = new PluginResult(PluginResult.Status.OK, TTS.STARTED); result.setKeepCallback(false); //this.success(result, this.startupCallbackId); this.startupCallbackContext.sendPluginResult(result); mTts.setOnUtteranceCompletedListener(this); // Putting this code in hear as a place holder. When everything moves to API level 15 or greater // we'll switch over to this way of trackign progress. // mTts.setOnUtteranceProgressListener(new UtteranceProgressListener() { // // @Override // public void onDone(String utteranceId) { // Log.d(LOG_TAG, "got completed utterance"); // PluginResult result = new PluginResult(PluginResult.Status.OK); // result.setKeepCallback(false); // callbackContext.sendPluginResult(result); // } // // @Override // public void onError(String utteranceId) { // Log.d(LOG_TAG, "got utterance error"); // PluginResult result = new PluginResult(PluginResult.Status.ERROR); // result.setKeepCallback(false); // callbackContext.sendPluginResult(result); // } // // @Override // public void onStart(String utteranceId) { // Log.d(LOG_TAG, "started talking"); // } // // }); } else if (status == TextToSpeech.ERROR) { state = TTS.STOPPED; PluginResult result = new PluginResult(PluginResult.Status.ERROR, TTS.STOPPED); result.setKeepCallback(false); this.startupCallbackContext.sendPluginResult(result); } }
From source file:org.digitalcampus.oppia.activity.CourseActivity.java
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) @SuppressLint("NewApi") public void onInit(int status) { // check for successful instantiation if (status == TextToSpeech.SUCCESS) { ttsRunning = true;//w w w .j a v a 2s . c o m ((WidgetFactory) apAdapter.getItem(currentActivityNo)).setReadAloud(true); supportInvalidateOptionsMenu(); HashMap<String, String> params = new HashMap<String, String>(); params.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, TAG); myTTS.speak(((WidgetFactory) apAdapter.getItem(currentActivityNo)).getContentToRead(), TextToSpeech.QUEUE_FLUSH, params); myTTS.setOnUtteranceProgressListener(new UtteranceProgressListener() { @Override public void onDone(String utteranceId) { Log.d(TAG, "Finished reading"); CourseActivity.this.ttsRunning = false; myTTS = null; } @Override public void onError(String utteranceId) { } @Override public void onStart(String utteranceId) { } }); } else { // TTS not installed so show message Toast.makeText(this, this.getString(R.string.error_tts_start), Toast.LENGTH_LONG).show(); } }
From source file:com.abid_mujtaba.fetchheaders.MainActivity.java
@Override public void onInit(int status) { if (status == TextToSpeech.SUCCESS) { int result = mTTS.setLanguage(Locale.US); if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) { Resources.Loge("This Language is not supported. result: " + result, null); Resources.Loge(/*from w w w . j av a 2s . c om*/ "If result is -1 simply install 'Speech Synthesis Data Installer' from the Google Play Store.", null); } else { return; } } mTTS.stop(); mTTS.shutdown(); mTTS = null; Resources.Loge("Initialization failed", null); }
From source file:com.nbplus.vbroadlauncher.service.BroadcastChatHeadService.java
@Override public void onInit(int status) { Log.d(TAG, "> TTS onInit()"); if (status != TextToSpeech.SUCCESS) { Log.e(TAG, String.format("TextToSpeechManager.onInit(%d) fail!", status)); Log.d(TAG, " ??.... ? ??..."); mText2Speech.shutdown();/*w w w. j a va 2 s. co m*/ mText2Speech = null; // TODO : ? ????? } else { int result = mText2Speech.setLanguage(Locale.KOREA); if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) { Log.e(TAG, String.format("TextToSpeech.setLanguage(%s) fail!", Locale.KOREA.getDisplayName())); // TODO : ? ????? mText2Speech.shutdown(); mText2Speech = null; } else { mText2SpeechHandler.setTextToSpeechObject(mText2Speech); mText2SpeechHandler.play(mBroadcastData.getMessage()); } } }