summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorCharles Chen <clchen@google.com>2010-04-01 17:56:47 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-04-01 17:56:47 -0700
commitddc2eb8ee3c422b9f57bf55c50a76c7afb4ced76 (patch)
treea70e793f8270ca68d86356296a88823b3c6cfe87 /packages
parente11bafec8d6c887c6ae95fa3d39c202859e86d48 (diff)
parent1a2712ce2a18eba6809d984d2f7443fbdccaa7ed (diff)
downloadframeworks_base-ddc2eb8ee3c422b9f57bf55c50a76c7afb4ced76.zip
frameworks_base-ddc2eb8ee3c422b9f57bf55c50a76c7afb4ced76.tar.gz
frameworks_base-ddc2eb8ee3c422b9f57bf55c50a76c7afb4ced76.tar.bz2
Merge "Fix for bug 2564771 - pitch setting between apps can interfere with one another." into froyo
Diffstat (limited to 'packages')
-rwxr-xr-xpackages/TtsService/src/android/tts/TtsService.java32
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);
}