Loading core/java/android/speech/tts/TextToSpeech.java +133 −11 Original line number Original line Diff line number Diff line Loading @@ -281,14 +281,20 @@ public class TextToSpeech { return TTS_SUCCESS; return TTS_SUCCESS; } catch (RemoteException e) { } catch (RemoteException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - addSpeech", "RemoteException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (NullPointerException e) { } catch (NullPointerException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - addSpeech", "NullPointerException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (IllegalStateException e) { } catch (IllegalStateException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - addSpeech", "IllegalStateException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } } Loading Loading @@ -319,14 +325,20 @@ public class TextToSpeech { return TTS_SUCCESS; return TTS_SUCCESS; } catch (RemoteException e) { } catch (RemoteException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - addSpeech", "RemoteException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (NullPointerException e) { } catch (NullPointerException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - addSpeech", "NullPointerException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (IllegalStateException e) { } catch (IllegalStateException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - addSpeech", "IllegalStateException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } } Loading Loading @@ -361,6 +373,7 @@ public class TextToSpeech { return result; return result; } } try { try { if ((params != null) && (!params.isEmpty())) { String extra = params.get(Engine.TTS_KEY_PARAM_STREAM); String extra = params.get(Engine.TTS_KEY_PARAM_STREAM); if (extra != null) { if (extra != null) { mCachedParams[Engine.TTS_PARAM_POSITION_STREAM + 1] = extra; mCachedParams[Engine.TTS_PARAM_POSITION_STREAM + 1] = extra; Loading @@ -369,17 +382,24 @@ public class TextToSpeech { if (extra != null) { if (extra != null) { mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID] = extra; mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID] = extra; } } } result = mITts.speak(mPackageName, text, queueMode, mCachedParams); result = mITts.speak(mPackageName, text, queueMode, mCachedParams); } catch (RemoteException e) { } catch (RemoteException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - speak", "RemoteException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (NullPointerException e) { } catch (NullPointerException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - speak", "NullPointerException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (IllegalStateException e) { } catch (IllegalStateException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - speak", "IllegalStateException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } finally { } finally { Loading Loading @@ -423,14 +443,20 @@ public class TextToSpeech { result = mITts.playEarcon(mPackageName, earcon, queueMode, null); result = mITts.playEarcon(mPackageName, earcon, queueMode, null); } catch (RemoteException e) { } catch (RemoteException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - playEarcon", "RemoteException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (NullPointerException e) { } catch (NullPointerException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - playEarcon", "NullPointerException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (IllegalStateException e) { } catch (IllegalStateException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - playEarcon", "IllegalStateException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } finally { } finally { Loading Loading @@ -461,14 +487,20 @@ public class TextToSpeech { result = mITts.playSilence(mPackageName, durationInMs, queueMode, mCachedParams); result = mITts.playSilence(mPackageName, durationInMs, queueMode, mCachedParams); } catch (RemoteException e) { } catch (RemoteException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - playSilence", "RemoteException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (NullPointerException e) { } catch (NullPointerException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - playSilence", "NullPointerException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (IllegalStateException e) { } catch (IllegalStateException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - playSilence", "IllegalStateException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } finally { } finally { Loading @@ -492,14 +524,20 @@ public class TextToSpeech { return mITts.isSpeaking(); return mITts.isSpeaking(); } catch (RemoteException e) { } catch (RemoteException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - isSpeaking", "RemoteException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (NullPointerException e) { } catch (NullPointerException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - isSpeaking", "NullPointerException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (IllegalStateException e) { } catch (IllegalStateException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - isSpeaking", "IllegalStateException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } } Loading @@ -523,14 +561,20 @@ public class TextToSpeech { result = mITts.stop(mPackageName); result = mITts.stop(mPackageName); } catch (RemoteException e) { } catch (RemoteException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - stop", "RemoteException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (NullPointerException e) { } catch (NullPointerException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - stop", "NullPointerException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (IllegalStateException e) { } catch (IllegalStateException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - stop", "IllegalStateException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } finally { } finally { Loading Loading @@ -569,6 +613,20 @@ public class TextToSpeech { } } } catch (RemoteException e) { } catch (RemoteException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - setSpeechRate", "RemoteException"); e.printStackTrace(); mStarted = false; initTts(); } catch (NullPointerException e) { // TTS died; restart it. Log.e("TextToSpeech.java - setSpeechRate", "NullPointerException"); e.printStackTrace(); mStarted = false; initTts(); } catch (IllegalStateException e) { // TTS died; restart it. Log.e("TextToSpeech.java - setSpeechRate", "IllegalStateException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } finally { } finally { Loading Loading @@ -605,6 +663,20 @@ public class TextToSpeech { } } } catch (RemoteException e) { } catch (RemoteException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - setPitch", "RemoteException"); e.printStackTrace(); mStarted = false; initTts(); } catch (NullPointerException e) { // TTS died; restart it. Log.e("TextToSpeech.java - setPitch", "NullPointerException"); e.printStackTrace(); mStarted = false; initTts(); } catch (IllegalStateException e) { // TTS died; restart it. Log.e("TextToSpeech.java - setPitch", "IllegalStateException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } finally { } finally { Loading Loading @@ -642,6 +714,20 @@ public class TextToSpeech { mCachedParams[Engine.TTS_PARAM_POSITION_VARIANT + 1] ); mCachedParams[Engine.TTS_PARAM_POSITION_VARIANT + 1] ); } catch (RemoteException e) { } catch (RemoteException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - setLanguage", "RemoteException"); e.printStackTrace(); mStarted = false; initTts(); } catch (NullPointerException e) { // TTS died; restart it. Log.e("TextToSpeech.java - setLanguage", "NullPointerException"); e.printStackTrace(); mStarted = false; initTts(); } catch (IllegalStateException e) { // TTS died; restart it. Log.e("TextToSpeech.java - setLanguage", "IllegalStateException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } finally { } finally { Loading Loading @@ -670,6 +756,20 @@ public class TextToSpeech { } } } catch (RemoteException e) { } catch (RemoteException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - getLanguage", "RemoteException"); e.printStackTrace(); mStarted = false; initTts(); } catch (NullPointerException e) { // TTS died; restart it. Log.e("TextToSpeech.java - getLanguage", "NullPointerException"); e.printStackTrace(); mStarted = false; initTts(); } catch (IllegalStateException e) { // TTS died; restart it. Log.e("TextToSpeech.java - getLanguage", "IllegalStateException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } } Loading Loading @@ -697,6 +797,20 @@ public class TextToSpeech { loc.getISO3Country(), loc.getVariant()); loc.getISO3Country(), loc.getVariant()); } catch (RemoteException e) { } catch (RemoteException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - isLanguageAvailable", "RemoteException"); e.printStackTrace(); mStarted = false; initTts(); } catch (NullPointerException e) { // TTS died; restart it. Log.e("TextToSpeech.java - isLanguageAvailable", "NullPointerException"); e.printStackTrace(); mStarted = false; initTts(); } catch (IllegalStateException e) { // TTS died; restart it. Log.e("TextToSpeech.java - isLanguageAvailable", "IllegalStateException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } finally { } finally { Loading Loading @@ -727,24 +841,32 @@ public class TextToSpeech { return result; return result; } } try { try { if ((params != null) && (!params.isEmpty())) { // no need to read the stream type here // no need to read the stream type here String extra = params.get(Engine.TTS_KEY_PARAM_UTTERANCE_ID); String extra = params.get(Engine.TTS_KEY_PARAM_UTTERANCE_ID); if (extra != null) { if (extra != null) { mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID] = extra; mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID] = extra; } } } if (mITts.synthesizeToFile(mPackageName, text, mCachedParams, filename)){ if (mITts.synthesizeToFile(mPackageName, text, mCachedParams, filename)){ result = TTS_SUCCESS; result = TTS_SUCCESS; } } } catch (RemoteException e) { } catch (RemoteException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - synthesizeToFile", "RemoteException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (NullPointerException e) { } catch (NullPointerException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - synthesizeToFile", "NullPointerException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (IllegalStateException e) { } catch (IllegalStateException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - synthesizeToFile", "IllegalStateException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } finally { } finally { Loading packages/TtsService/src/android/tts/TtsService.java +22 −17 Original line number Original line Diff line number Diff line Loading @@ -132,7 +132,7 @@ public class TtsService extends Service implements OnCompletionListener { @Override @Override public void onCreate() { public void onCreate() { super.onCreate(); super.onCreate(); //Log.i("TTS", "TTS starting"); Log.i("TTS", "TTS starting"); mResolver = getContentResolver(); mResolver = getContentResolver(); Loading Loading @@ -326,6 +326,7 @@ public class TtsService extends Service implements OnCompletionListener { * engines. * engines. */ */ private int speak(String callingApp, String text, int queueMode, ArrayList<String> params) { private int speak(String callingApp, String text, int queueMode, ArrayList<String> params) { Log.i("TTS service received", text); if (queueMode == TextToSpeech.TTS_QUEUE_FLUSH) { if (queueMode == TextToSpeech.TTS_QUEUE_FLUSH) { stop(callingApp); stop(callingApp); } } Loading Loading @@ -455,6 +456,7 @@ public class TtsService extends Service implements OnCompletionListener { String variant = ""; String variant = ""; for (int i = 0; i < params.size() - 1; i = i + 2){ for (int i = 0; i < params.size() - 1; i = i + 2){ String param = params.get(i); String param = params.get(i); if (param != null){ if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_RATE)){ if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_RATE)){ setSpeechRate("", Integer.parseInt(params.get(i+1))); setSpeechRate("", Integer.parseInt(params.get(i+1))); } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_LANGUAGE)){ } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_LANGUAGE)){ Loading @@ -465,6 +467,7 @@ public class TtsService extends Service implements OnCompletionListener { variant = params.get(i+1); variant = params.get(i+1); } } } } } if (language.length() > 0){ if (language.length() > 0){ setLanguage("", language, country, variant); setLanguage("", language, country, variant); } } Loading Loading @@ -510,6 +513,7 @@ public class TtsService extends Service implements OnCompletionListener { String variant = ""; String variant = ""; for (int i = 0; i < params.size() - 1; i = i + 2){ for (int i = 0; i < params.size() - 1; i = i + 2){ String param = params.get(i); String param = params.get(i); if (param != null){ if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_RATE)){ if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_RATE)){ setSpeechRate("", Integer.parseInt(params.get(i+1))); setSpeechRate("", Integer.parseInt(params.get(i+1))); } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_LANGUAGE)){ } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_LANGUAGE)){ Loading @@ -520,6 +524,7 @@ public class TtsService extends Service implements OnCompletionListener { variant = params.get(i+1); variant = params.get(i+1); } } } } } if (language.length() > 0){ if (language.length() > 0){ setLanguage("", language, country, variant); setLanguage("", language, country, variant); } } Loading Loading
core/java/android/speech/tts/TextToSpeech.java +133 −11 Original line number Original line Diff line number Diff line Loading @@ -281,14 +281,20 @@ public class TextToSpeech { return TTS_SUCCESS; return TTS_SUCCESS; } catch (RemoteException e) { } catch (RemoteException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - addSpeech", "RemoteException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (NullPointerException e) { } catch (NullPointerException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - addSpeech", "NullPointerException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (IllegalStateException e) { } catch (IllegalStateException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - addSpeech", "IllegalStateException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } } Loading Loading @@ -319,14 +325,20 @@ public class TextToSpeech { return TTS_SUCCESS; return TTS_SUCCESS; } catch (RemoteException e) { } catch (RemoteException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - addSpeech", "RemoteException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (NullPointerException e) { } catch (NullPointerException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - addSpeech", "NullPointerException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (IllegalStateException e) { } catch (IllegalStateException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - addSpeech", "IllegalStateException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } } Loading Loading @@ -361,6 +373,7 @@ public class TextToSpeech { return result; return result; } } try { try { if ((params != null) && (!params.isEmpty())) { String extra = params.get(Engine.TTS_KEY_PARAM_STREAM); String extra = params.get(Engine.TTS_KEY_PARAM_STREAM); if (extra != null) { if (extra != null) { mCachedParams[Engine.TTS_PARAM_POSITION_STREAM + 1] = extra; mCachedParams[Engine.TTS_PARAM_POSITION_STREAM + 1] = extra; Loading @@ -369,17 +382,24 @@ public class TextToSpeech { if (extra != null) { if (extra != null) { mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID] = extra; mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID] = extra; } } } result = mITts.speak(mPackageName, text, queueMode, mCachedParams); result = mITts.speak(mPackageName, text, queueMode, mCachedParams); } catch (RemoteException e) { } catch (RemoteException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - speak", "RemoteException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (NullPointerException e) { } catch (NullPointerException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - speak", "NullPointerException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (IllegalStateException e) { } catch (IllegalStateException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - speak", "IllegalStateException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } finally { } finally { Loading Loading @@ -423,14 +443,20 @@ public class TextToSpeech { result = mITts.playEarcon(mPackageName, earcon, queueMode, null); result = mITts.playEarcon(mPackageName, earcon, queueMode, null); } catch (RemoteException e) { } catch (RemoteException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - playEarcon", "RemoteException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (NullPointerException e) { } catch (NullPointerException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - playEarcon", "NullPointerException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (IllegalStateException e) { } catch (IllegalStateException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - playEarcon", "IllegalStateException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } finally { } finally { Loading Loading @@ -461,14 +487,20 @@ public class TextToSpeech { result = mITts.playSilence(mPackageName, durationInMs, queueMode, mCachedParams); result = mITts.playSilence(mPackageName, durationInMs, queueMode, mCachedParams); } catch (RemoteException e) { } catch (RemoteException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - playSilence", "RemoteException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (NullPointerException e) { } catch (NullPointerException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - playSilence", "NullPointerException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (IllegalStateException e) { } catch (IllegalStateException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - playSilence", "IllegalStateException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } finally { } finally { Loading @@ -492,14 +524,20 @@ public class TextToSpeech { return mITts.isSpeaking(); return mITts.isSpeaking(); } catch (RemoteException e) { } catch (RemoteException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - isSpeaking", "RemoteException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (NullPointerException e) { } catch (NullPointerException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - isSpeaking", "NullPointerException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (IllegalStateException e) { } catch (IllegalStateException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - isSpeaking", "IllegalStateException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } } Loading @@ -523,14 +561,20 @@ public class TextToSpeech { result = mITts.stop(mPackageName); result = mITts.stop(mPackageName); } catch (RemoteException e) { } catch (RemoteException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - stop", "RemoteException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (NullPointerException e) { } catch (NullPointerException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - stop", "NullPointerException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (IllegalStateException e) { } catch (IllegalStateException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - stop", "IllegalStateException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } finally { } finally { Loading Loading @@ -569,6 +613,20 @@ public class TextToSpeech { } } } catch (RemoteException e) { } catch (RemoteException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - setSpeechRate", "RemoteException"); e.printStackTrace(); mStarted = false; initTts(); } catch (NullPointerException e) { // TTS died; restart it. Log.e("TextToSpeech.java - setSpeechRate", "NullPointerException"); e.printStackTrace(); mStarted = false; initTts(); } catch (IllegalStateException e) { // TTS died; restart it. Log.e("TextToSpeech.java - setSpeechRate", "IllegalStateException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } finally { } finally { Loading Loading @@ -605,6 +663,20 @@ public class TextToSpeech { } } } catch (RemoteException e) { } catch (RemoteException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - setPitch", "RemoteException"); e.printStackTrace(); mStarted = false; initTts(); } catch (NullPointerException e) { // TTS died; restart it. Log.e("TextToSpeech.java - setPitch", "NullPointerException"); e.printStackTrace(); mStarted = false; initTts(); } catch (IllegalStateException e) { // TTS died; restart it. Log.e("TextToSpeech.java - setPitch", "IllegalStateException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } finally { } finally { Loading Loading @@ -642,6 +714,20 @@ public class TextToSpeech { mCachedParams[Engine.TTS_PARAM_POSITION_VARIANT + 1] ); mCachedParams[Engine.TTS_PARAM_POSITION_VARIANT + 1] ); } catch (RemoteException e) { } catch (RemoteException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - setLanguage", "RemoteException"); e.printStackTrace(); mStarted = false; initTts(); } catch (NullPointerException e) { // TTS died; restart it. Log.e("TextToSpeech.java - setLanguage", "NullPointerException"); e.printStackTrace(); mStarted = false; initTts(); } catch (IllegalStateException e) { // TTS died; restart it. Log.e("TextToSpeech.java - setLanguage", "IllegalStateException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } finally { } finally { Loading Loading @@ -670,6 +756,20 @@ public class TextToSpeech { } } } catch (RemoteException e) { } catch (RemoteException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - getLanguage", "RemoteException"); e.printStackTrace(); mStarted = false; initTts(); } catch (NullPointerException e) { // TTS died; restart it. Log.e("TextToSpeech.java - getLanguage", "NullPointerException"); e.printStackTrace(); mStarted = false; initTts(); } catch (IllegalStateException e) { // TTS died; restart it. Log.e("TextToSpeech.java - getLanguage", "IllegalStateException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } } Loading Loading @@ -697,6 +797,20 @@ public class TextToSpeech { loc.getISO3Country(), loc.getVariant()); loc.getISO3Country(), loc.getVariant()); } catch (RemoteException e) { } catch (RemoteException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - isLanguageAvailable", "RemoteException"); e.printStackTrace(); mStarted = false; initTts(); } catch (NullPointerException e) { // TTS died; restart it. Log.e("TextToSpeech.java - isLanguageAvailable", "NullPointerException"); e.printStackTrace(); mStarted = false; initTts(); } catch (IllegalStateException e) { // TTS died; restart it. Log.e("TextToSpeech.java - isLanguageAvailable", "IllegalStateException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } finally { } finally { Loading Loading @@ -727,24 +841,32 @@ public class TextToSpeech { return result; return result; } } try { try { if ((params != null) && (!params.isEmpty())) { // no need to read the stream type here // no need to read the stream type here String extra = params.get(Engine.TTS_KEY_PARAM_UTTERANCE_ID); String extra = params.get(Engine.TTS_KEY_PARAM_UTTERANCE_ID); if (extra != null) { if (extra != null) { mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID] = extra; mCachedParams[Engine.TTS_PARAM_POSITION_UTTERANCE_ID] = extra; } } } if (mITts.synthesizeToFile(mPackageName, text, mCachedParams, filename)){ if (mITts.synthesizeToFile(mPackageName, text, mCachedParams, filename)){ result = TTS_SUCCESS; result = TTS_SUCCESS; } } } catch (RemoteException e) { } catch (RemoteException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - synthesizeToFile", "RemoteException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (NullPointerException e) { } catch (NullPointerException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - synthesizeToFile", "NullPointerException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } catch (IllegalStateException e) { } catch (IllegalStateException e) { // TTS died; restart it. // TTS died; restart it. Log.e("TextToSpeech.java - synthesizeToFile", "IllegalStateException"); e.printStackTrace(); mStarted = false; mStarted = false; initTts(); initTts(); } finally { } finally { Loading
packages/TtsService/src/android/tts/TtsService.java +22 −17 Original line number Original line Diff line number Diff line Loading @@ -132,7 +132,7 @@ public class TtsService extends Service implements OnCompletionListener { @Override @Override public void onCreate() { public void onCreate() { super.onCreate(); super.onCreate(); //Log.i("TTS", "TTS starting"); Log.i("TTS", "TTS starting"); mResolver = getContentResolver(); mResolver = getContentResolver(); Loading Loading @@ -326,6 +326,7 @@ public class TtsService extends Service implements OnCompletionListener { * engines. * engines. */ */ private int speak(String callingApp, String text, int queueMode, ArrayList<String> params) { private int speak(String callingApp, String text, int queueMode, ArrayList<String> params) { Log.i("TTS service received", text); if (queueMode == TextToSpeech.TTS_QUEUE_FLUSH) { if (queueMode == TextToSpeech.TTS_QUEUE_FLUSH) { stop(callingApp); stop(callingApp); } } Loading Loading @@ -455,6 +456,7 @@ public class TtsService extends Service implements OnCompletionListener { String variant = ""; String variant = ""; for (int i = 0; i < params.size() - 1; i = i + 2){ for (int i = 0; i < params.size() - 1; i = i + 2){ String param = params.get(i); String param = params.get(i); if (param != null){ if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_RATE)){ if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_RATE)){ setSpeechRate("", Integer.parseInt(params.get(i+1))); setSpeechRate("", Integer.parseInt(params.get(i+1))); } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_LANGUAGE)){ } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_LANGUAGE)){ Loading @@ -465,6 +467,7 @@ public class TtsService extends Service implements OnCompletionListener { variant = params.get(i+1); variant = params.get(i+1); } } } } } if (language.length() > 0){ if (language.length() > 0){ setLanguage("", language, country, variant); setLanguage("", language, country, variant); } } Loading Loading @@ -510,6 +513,7 @@ public class TtsService extends Service implements OnCompletionListener { String variant = ""; String variant = ""; for (int i = 0; i < params.size() - 1; i = i + 2){ for (int i = 0; i < params.size() - 1; i = i + 2){ String param = params.get(i); String param = params.get(i); if (param != null){ if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_RATE)){ if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_RATE)){ setSpeechRate("", Integer.parseInt(params.get(i+1))); setSpeechRate("", Integer.parseInt(params.get(i+1))); } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_LANGUAGE)){ } else if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_LANGUAGE)){ Loading @@ -520,6 +524,7 @@ public class TtsService extends Service implements OnCompletionListener { variant = params.get(i+1); variant = params.get(i+1); } } } } } if (language.length() > 0){ if (language.length() > 0){ setLanguage("", language, country, variant); setLanguage("", language, country, variant); } } Loading