summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Charles Chen <clchen@google.com> 2010-03-01 19:05:20 -0800
committer Android (Google) Code Review <android-gerrit@google.com> 2010-03-01 19:05:20 -0800
commit883dbacb12a003f8f46c3faab26b744fdef649a1 (patch)
treeb8511c0351bf1972be6c86162c4db21de01c7997
parent31901cc0b6f0c678be4f629c8c3405700e63c346 (diff)
parent6a8b73be572f37b471322e7d49b44c3783633d96 (diff)
Merge "Fixing a bug with TTS that caused TTS to ignore the default settings unless the user had set the defaults to always override app settings."
-rwxr-xr-xcore/java/android/speech/tts/TextToSpeech.java16
-rwxr-xr-xpackages/TtsService/src/android/tts/TtsService.java17
2 files changed, 25 insertions, 8 deletions
diff --git a/core/java/android/speech/tts/TextToSpeech.java b/core/java/android/speech/tts/TextToSpeech.java
index 0db21980e44a..9e04cf8a55d7 100755
--- a/core/java/android/speech/tts/TextToSpeech.java
+++ b/core/java/android/speech/tts/TextToSpeech.java
@@ -410,17 +410,17 @@ public class TextToSpeech {
mCachedParams[Engine.PARAM_POSITION_UTTERANCE_ID] = Engine.KEY_PARAM_UTTERANCE_ID;
mCachedParams[Engine.PARAM_POSITION_ENGINE] = Engine.KEY_PARAM_ENGINE;
- mCachedParams[Engine.PARAM_POSITION_RATE + 1] =
- String.valueOf(Engine.DEFAULT_RATE);
- // initialize the language cached parameters with the current Locale
- Locale defaultLoc = Locale.getDefault();
- mCachedParams[Engine.PARAM_POSITION_LANGUAGE + 1] = defaultLoc.getISO3Language();
- mCachedParams[Engine.PARAM_POSITION_COUNTRY + 1] = defaultLoc.getISO3Country();
- mCachedParams[Engine.PARAM_POSITION_VARIANT + 1] = defaultLoc.getVariant();
+ // Leave all defaults that are shown in Settings uninitialized so that
+ // the values set in Settings will take effect if the application does
+ // not try to change these settings itself.
+ mCachedParams[Engine.PARAM_POSITION_RATE + 1] = "";
+ mCachedParams[Engine.PARAM_POSITION_LANGUAGE + 1] = "";
+ mCachedParams[Engine.PARAM_POSITION_COUNTRY + 1] = "";
+ mCachedParams[Engine.PARAM_POSITION_VARIANT + 1] = "";
mCachedParams[Engine.PARAM_POSITION_STREAM + 1] =
String.valueOf(Engine.DEFAULT_STREAM);
mCachedParams[Engine.PARAM_POSITION_UTTERANCE_ID + 1] = "";
- mCachedParams[Engine.PARAM_POSITION_ENGINE + 1] = Engine.DEFAULT_SYNTH;
+ mCachedParams[Engine.PARAM_POSITION_ENGINE + 1] = "";
initTts();
}
diff --git a/packages/TtsService/src/android/tts/TtsService.java b/packages/TtsService/src/android/tts/TtsService.java
index c0e4cc0d393d..7f76425dcca7 100755
--- a/packages/TtsService/src/android/tts/TtsService.java
+++ b/packages/TtsService/src/android/tts/TtsService.java
@@ -206,6 +206,9 @@ public class TtsService extends Service implements OnCompletionListener {
private int setEngine(String enginePackageName) {
String soFilename = "";
+ if (isDefaultEnforced()) {
+ enginePackageName = getDefaultEngine();
+ }
// The SVOX TTS is an exception to how the TTS packaging scheme works
// because it is part of the system and not a 3rd party add-on; thus
// its binary is actually located under /system/lib/
@@ -779,12 +782,19 @@ public class TtsService extends Service implements OnCompletionListener {
if (mKillList.get(speechItem) == null) {
if (engine.length() > 0) {
setEngine(engine);
+ } else {
+ setEngine(getDefaultEngine());
}
if (language.length() > 0){
setLanguage("", language, country, variant);
+ } else {
+ setLanguage("", getDefaultLanguage(), getDefaultCountry(),
+ getDefaultLocVariant());
}
if (speechRate.length() > 0){
setSpeechRate("", Integer.parseInt(speechRate));
+ } else {
+ setSpeechRate("", getDefaultRate());
}
try {
sNativeSynth.speak(speechItem.mText, streamType);
@@ -864,12 +874,19 @@ public class TtsService extends Service implements OnCompletionListener {
if (mKillList.get(speechItem) == null){
if (engine.length() > 0) {
setEngine(engine);
+ } else {
+ setEngine(getDefaultEngine());
}
if (language.length() > 0){
setLanguage("", language, country, variant);
+ } else {
+ setLanguage("", getDefaultLanguage(), getDefaultCountry(),
+ getDefaultLocVariant());
}
if (speechRate.length() > 0){
setSpeechRate("", Integer.parseInt(speechRate));
+ } else {
+ setSpeechRate("", getDefaultRate());
}
try {
sNativeSynth.synthesizeToFile(speechItem.mText, speechItem.mFilename);