diff options
author | Charles Chen <clchen@google.com> | 2010-04-01 17:16:28 -0700 |
---|---|---|
committer | Charles Chen <clchen@google.com> | 2010-04-01 17:39:15 -0700 |
commit | 1a2712ce2a18eba6809d984d2f7443fbdccaa7ed (patch) | |
tree | 196f3028a13a0ed829e258417a85d41ed54a03de /packages | |
parent | 9d32d24dbd8a015c9d5c44ed4901d5a666eb8e7f (diff) | |
download | frameworks_base-1a2712ce2a18eba6809d984d2f7443fbdccaa7ed.zip frameworks_base-1a2712ce2a18eba6809d984d2f7443fbdccaa7ed.tar.gz frameworks_base-1a2712ce2a18eba6809d984d2f7443fbdccaa7ed.tar.bz2 |
Fix for bug 2564771 - pitch setting between apps can
interfere with one another.
Root cause was not caching all the params that were needed.
This change fixes that bug as well as related bugs for remembering
the default engine and for making sure that the right engine is
loaded when checking for language availability.
Change-Id: I2a76da8faec8112036e68d27539db444c53a1509
Diffstat (limited to 'packages')
-rwxr-xr-x | packages/TtsService/src/android/tts/TtsService.java | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/packages/TtsService/src/android/tts/TtsService.java b/packages/TtsService/src/android/tts/TtsService.java index 530ca57..c977ba3 100755 --- a/packages/TtsService/src/android/tts/TtsService.java +++ b/packages/TtsService/src/android/tts/TtsService.java @@ -321,6 +321,10 @@ public class TtsService extends Service implements OnCompletionListener { TextToSpeech.Engine.DEFAULT_RATE); } + private int getDefaultPitch() { + // Pitch is not user settable; the default pitch is always 100. + return 100; + } private String getDefaultLanguage() { String defaultLang = android.provider.Settings.Secure.getString(mResolver, @@ -786,6 +790,7 @@ public class TtsService extends Service implements OnCompletionListener { String variant = ""; String speechRate = ""; String engine = ""; + String pitch = ""; if (speechItem.mParams != null){ for (int i = 0; i < speechItem.mParams.size() - 1; i = i + 2){ String param = speechItem.mParams.get(i); @@ -809,6 +814,8 @@ public class TtsService extends Service implements OnCompletionListener { } } else if (param.equals(TextToSpeech.Engine.KEY_PARAM_ENGINE)) { engine = speechItem.mParams.get(i + 1); + } else if (param.equals(TextToSpeech.Engine.KEY_PARAM_PITCH)) { + pitch = speechItem.mParams.get(i + 1); } } } @@ -831,6 +838,11 @@ public class TtsService extends Service implements OnCompletionListener { } else { setSpeechRate("", getDefaultRate()); } + if (pitch.length() > 0){ + setPitch("", Integer.parseInt(pitch)); + } else { + setPitch("", getDefaultPitch()); + } try { sNativeSynth.speak(speechItem.mText, streamType); } catch (NullPointerException e) { @@ -885,6 +897,7 @@ public class TtsService extends Service implements OnCompletionListener { String variant = ""; String speechRate = ""; String engine = ""; + String pitch = ""; if (speechItem.mParams != null){ for (int i = 0; i < speechItem.mParams.size() - 1; i = i + 2){ String param = speechItem.mParams.get(i); @@ -901,6 +914,8 @@ public class TtsService extends Service implements OnCompletionListener { utteranceId = speechItem.mParams.get(i+1); } else if (param.equals(TextToSpeech.Engine.KEY_PARAM_ENGINE)) { engine = speechItem.mParams.get(i + 1); + } else if (param.equals(TextToSpeech.Engine.KEY_PARAM_PITCH)) { + pitch = speechItem.mParams.get(i + 1); } } } @@ -923,6 +938,11 @@ public class TtsService extends Service implements OnCompletionListener { } else { setSpeechRate("", getDefaultRate()); } + if (pitch.length() > 0){ + setPitch("", Integer.parseInt(pitch)); + } else { + setPitch("", getDefaultPitch()); + } try { sNativeSynth.synthesizeToFile(speechItem.mText, speechItem.mFilename); } catch (NullPointerException e) { @@ -1377,7 +1397,17 @@ public class TtsService extends Service implements OnCompletionListener { * TTS_LANG_COUNTRY_AVAILABLE, TTS_LANG_COUNTRY_VAR_AVAILABLE as defined in * android.speech.tts.TextToSpeech. */ - public int isLanguageAvailable(String lang, String country, String variant) { + public int isLanguageAvailable(String lang, String country, String variant, + String[] params) { + for (int i = 0; i < params.length - 1; i = i + 2){ + String param = params[i]; + if (param != null) { + if (param.equals(TextToSpeech.Engine.KEY_PARAM_ENGINE)) { + mSelf.setEngine(params[i + 1]); + break; + } + } + } return mSelf.isLanguageAvailable(lang, country, variant); } |