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.github.olga_yakovleva.rhvoice.android.RHVoiceService.java
@Override public int onIsValidVoiceName(String name) { if (BuildConfig.DEBUG) Log.v(TAG, "onIsValidVoiceName called for name " + name); Tts tts = ttsManager.get();/*from w ww . j a v a 2 s .co m*/ if (tts == null) return TextToSpeech.ERROR; if (tts.voiceIndex.containsKey(name)) { if (BuildConfig.DEBUG) Log.v(TAG, "Voice found"); return TextToSpeech.SUCCESS; } else { if (BuildConfig.DEBUG) Log.v(TAG, "Voice not found"); return TextToSpeech.ERROR; } }
From source file:com.github.olga_yakovleva.rhvoice.android.RHVoiceService.java
@Override public int onLoadVoice(String name) { return TextToSpeech.SUCCESS; }
From source file:com.example.app_2.activities.ImageGridActivity.java
@Override public void onInit(int status) { int result;//w ww . j a va2s. co m if (status == TextToSpeech.SUCCESS) { Locale pol_loc = new Locale("pl", "pl_PL"); if (TextToSpeech.LANG_AVAILABLE == tts.isLanguageAvailable(pol_loc)) { result = tts.setLanguage(pol_loc); if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) { Log.e("TTS", "LANG_NOT_SUPPORTED"); } } else { result = tts.setLanguage(Locale.ENGLISH); } } else { Log.e("TTS", "Initialization Failed"); } }
From source file:com.theultimatelabs.scale.ScaleActivity.java
public void onInit(int status) { if (status == TextToSpeech.SUCCESS) { mTts.setLanguage(Locale.US); mTts.setPitch(.9f);/* w ww . j a v a2s .c o m*/ } else { Log.e(TAG, "TTS Initilization Failed!"); } // TODO Auto-generated method stub }
From source file:org.de.jmg.learn.MainActivity.java
private void StartTextToSpeech() { tts = new TextToSpeech(this, new TextToSpeech.OnInitListener() { @Override/* w ww. j av a2 s . c o m*/ public void onInit(int status) { if (status == TextToSpeech.SUCCESS) { int res = tts.setLanguage(Locale.US); if (res < 0) { blnTextToSpeech = false; } else { tts.setSpeechRate(.75f); } } else { blnTextToSpeech = false; } } }); }
From source file:org.tlhInganHol.android.klingonassistant.EntryActivity.java
public void onInit(int status) { // status can be either TextToSpeech.SUCCESS or TextToSpeech.ERROR. if (status == TextToSpeech.SUCCESS) { // Set preferred language to Canadian Klingon. // Note that a language may not be available, and the result will indicate this. int result = mTts.setLanguage(new Locale("tlh", "", "")); if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) { // Lanuage data is missing or the language is not supported. Log.e(TAG, "Language is not available."); } else {//from w w w. j a v a2s . c o m // Check the documentation for other possible result codes. // For example, the language may be available for the locale, // but not for the specified country and variant. // The TTS engine has been successfully initialized. ttsInitialized = true; if (mSpeakButton != null) { // Log.d(TAG, "enabling TTS button in onInit"); mSpeakButton.setVisible(true); } } } else { // Initialization failed. Log.e(TAG, "Could not initialize TextToSpeech."); } }
From source file:net.nightwhistler.pageturner.fragment.ReadingFragment.java
private void streamPartToDisk(String fileName, String part, int offset, int totalLength, boolean endOfPage) throws TTSFailedException { LOG.debug("Request to stream text to file " + fileName + " with text " + part); if (part.trim().length() > 0 || endOfPage) { HashMap<String, String> params = new HashMap<>(); params.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, fileName); TTSPlaybackItem item = new TTSPlaybackItem(part, new MediaPlayer(), totalLength, offset, endOfPage, fileName);//from ww w .j a v a 2 s. co m ttsItemPrep.put(fileName, item); int result; String errorMessage = ""; try { result = textToSpeech.synthesizeToFile(part, params, fileName); } catch (Exception e) { LOG.error("Failed to start TTS", e); result = TextToSpeech.ERROR; errorMessage = e.getMessage(); } if (result != TextToSpeech.SUCCESS) { String message = "Can't write to file \n" + fileName + " because of error\n" + errorMessage; LOG.error(message); showTTSFailed(message); throw new TTSFailedException(); } } else { LOG.debug("Skipping part, since it's empty."); } }
From source file:com.lofland.housebot.BotController.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 {// w w w . j a va 2 s. co m btnSpeak.setEnabled(true); speakOut(); } } else { Log.e("TTS", "Initilization Failed!"); } }
From source file:com.aujur.ebookreader.activity.ReadingFragment.java
private void streamPartToDisk(String fileName, String part, int offset, int totalLength, boolean endOfPage) throws TTSFailedException { LOG.debug("Request to stream text to file " + fileName + " with text " + part); if (part.trim().length() > 0 || endOfPage) { HashMap<String, String> params = new HashMap<String, String>(); params.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, fileName); TTSPlaybackItem item = new TTSPlaybackItem(part, new MediaPlayer(), totalLength, offset, endOfPage, fileName);/*from w w w . j ava 2 s. c om*/ ttsItemPrep.put(fileName, item); int result = textToSpeech.synthesizeToFile(part, params, fileName); if (result != TextToSpeech.SUCCESS) { String message = "synthesizeToFile failed with result " + result; LOG.error(message); showTTSFailed(message); throw new TTSFailedException(); } } else { LOG.debug("Skipping part, since it's empty."); } }
From source file:com.air.mobilebrowser.BrowserActivity.java
@SuppressWarnings("deprecation") @Override// w w w . j a v a 2 s . c o m public void onInit(int status) { if (status == TextToSpeech.SUCCESS) { int result = ttsPlayer.getTextToSpeech().setLanguage(Locale.US); if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) { Log.e(TAG, "Language data missing or not supported"); mDeviceStatus.ttsEngineStatus = DeviceStatus.TTS_ENGINE_STATUS_UNAVAILABLE; } else { mDeviceStatus.ttsEngineStatus = DeviceStatus.TTS_ENGINE_STATUS_IDLE; } } else { Log.e(TAG, "Unable to initialize TextToSpeech (status: " + status + ")"); mDeviceStatus.ttsEngineStatus = DeviceStatus.TTS_ENGINE_STATUS_UNAVAILABLE; } // Notification of completion comes in on different thread, currently // UI updates necessary in executeAIRMobileFunction super.runOnUiThread(new Runnable() { @Override public void run() { JSONObject jsonToSend = new JSONObject(); try { jsonToSend.put(JSKeys.TTS_ENABLED, mDeviceStatus.ttsEnabled); jsonToSend.put(JSKeys.TTS_ENGINE_STATUS, mDeviceStatus.ttsEngineStatus); executeAIRMobileFunction(JSNTVCmds.NTV_ON_TTS_ENABLED, jsonToSend.toString()); } catch (JSONException e) { e.printStackTrace(); } } }); }