VoiceSettings.java: Support reading the default_pitch and espeak_pitch preferences.

This commit is contained in:
Reece H. Dunn
2013-09-04 17:17:11 +01:00
parent 54ccfc39b4
commit f47729453f
2 changed files with 73 additions and 0 deletions
@@ -26,6 +26,8 @@ public class VoiceSettings {
public static final String PREF_VARIANT = "espeak_variant";
public static final String PREF_DEFAULT_RATE = "default_rate";
public static final String PREF_RATE = "espeak_rate";
public static final String PREF_DEFAULT_PITCH = "default_pitch";
public static final String PREF_PITCH = "espeak_pitch";
public VoiceSettings(SharedPreferences preferences, SpeechSynthesis engine) {
mPreferences = preferences;
@@ -58,6 +60,20 @@ public class VoiceSettings {
return rate;
}
public int getPitch() {
int min = mEngine.Pitch.getMinValue();
int max = mEngine.Pitch.getMaxValue();
int pitch = getPreferenceValue(PREF_PITCH, Integer.MIN_VALUE);
if (pitch == Integer.MIN_VALUE) {
pitch = getPreferenceValue(PREF_DEFAULT_PITCH, 100) / 2;
}
if (pitch > max) pitch = max;
if (pitch < min) pitch = min;
return pitch;
}
private int getPreferenceValue(String preference, int defaultValue) {
String prefString = mPreferences.getString(preference, null);
if (prefString == null) {