Browse Source

When upgrading the speech rate, clamp it to between the default and maximum values.

master
Reece H. Dunn 12 years ago
parent
commit
ce8f261495
1 changed files with 6 additions and 1 deletions
  1. 6
    1
      android/src/com/reecedunn/espeak/TtsSettingsActivity.java

+ 6
- 1
android/src/com/reecedunn/espeak/TtsSettingsActivity.java View File

@@ -52,8 +52,13 @@ public class TtsSettingsActivity extends PreferenceActivity {
if (rate == null) {
// Try the old eyes-free setting:
SpeechSynthesis engine = new SpeechSynthesis(this, null);
int defaultValue = engine.Rate.getDefaultValue();
int maxValue = engine.Rate.getMaxValue();

rate = prefs.getString("default_rate", "100");
int rateValue = (Integer.parseInt(rate) / 100) * engine.Rate.getDefaultValue();
int rateValue = (Integer.parseInt(rate) / 100) * defaultValue;
if (rateValue < defaultValue) rateValue = defaultValue;
if (rateValue > maxValue) rateValue = maxValue;
editor.putString("espeak_rate", Integer.toString(rateValue));
}


Loading…
Cancel
Save