diff options
author | shwetachahar <shwetachahar@google.com> | 2016-04-06 14:44:18 +0100 |
---|---|---|
committer | shwetachahar <shwetachahar@google.com> | 2016-04-07 12:26:01 +0100 |
commit | b804b8ee1b34e0cf516550bd1b32f6cb032e8b65 (patch) | |
tree | e7722ef9a6be78e94c31ee1e71d1b88cc2c696d2 /src/com/android/settings/tts | |
parent | 90aec184b4229afca5cd7ae549b49ae8f93fd1e7 (diff) | |
download | packages_apps_Settings-b804b8ee1b34e0cf516550bd1b32f6cb032e8b65.tar.gz packages_apps_Settings-b804b8ee1b34e0cf516550bd1b32f6cb032e8b65.tar.bz2 packages_apps_Settings-b804b8ee1b34e0cf516550bd1b32f6cb032e8b65.zip |
Modify the pitch seekbar range to 25 to 400 in accordance with the pitch
range accepted by the Google Text-to-Speech engine.
Bug: 27871182
Change-Id: Ic6afde8fe6738f9313242beda12bbe4ba14e98bb
modified: src/com/android/settings/tts/TextToSpeechSettings.java
modified: src/com/android/settings/tts/TextToSpeechSettings.java
Diffstat (limited to 'src/com/android/settings/tts')
-rw-r--r-- | src/com/android/settings/tts/TextToSpeechSettings.java | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/src/com/android/settings/tts/TextToSpeechSettings.java b/src/com/android/settings/tts/TextToSpeechSettings.java index c8f7b8881d..0a488748a9 100644 --- a/src/com/android/settings/tts/TextToSpeechSettings.java +++ b/src/com/android/settings/tts/TextToSpeechSettings.java @@ -93,14 +93,15 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements private static final int MAX_SPEECH_RATE = 600; /** - * Maximum speech pitch value. Pitch value varies from 50 to 500, where 100 - * is the value for normal pitch. The max pitch value is set to 500, based on - * feedback from a few accessibility users. The range for pitch is not set in stone, + * Speech pitch value. + * TTS pitch value varies from 25 to 400, where 100 is the value + * for normal pitch. The max pitch value is set to 400, based on feedback from users + * and the GoogleTTS pitch variation range. The range for pitch is not set in stone * and should be readjusted based on user need. - * * This value should be kept in sync with the max value set in tts_settings xml. */ - private static final int MAX_SPEECH_PITCH = 500; + private static final int MAX_SPEECH_PITCH = 400; + private static final int MIN_SPEECH_PITCH = 25; private PreferenceCategory mEnginePreferenceCategory; private SeekBarPreference mDefaultPitchPref; @@ -264,9 +265,9 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements mDefaultRatePref.setOnPreferenceChangeListener(this); mDefaultRatePref.setMax(MAX_SPEECH_RATE); - mDefaultPitchPref.setProgress(mDefaultPitch); + mDefaultPitchPref.setProgress(getPitchSeekBarProgressFromSpeechPitchValue(mDefaultPitch)); mDefaultPitchPref.setOnPreferenceChangeListener(this); - mDefaultPitchPref.setMax(MAX_SPEECH_PITCH); + mDefaultPitchPref.setMax(getPitchSeekBarProgressFromSpeechPitchValue(MAX_SPEECH_PITCH)); mCurrentEngine = mTts.getCurrentEngine(); @@ -291,6 +292,24 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements } /** + * The minimum pitch value should be > 0 but the minimum value of a seekbar in android + * is fixed at 0. Therefore, we increment the seekbar progress with MIN_SPEECH_PITCH value + * so that the minimum seekbar progress value is MIN_SPEECH_PITCH. + * PITCH_VALUE = MIN_SPEECH_PITCH + PITCH_SEEKBAR_PROGRESS + */ + private int getSpeechPitchValueFromSeekBarProgress(int progress) { + return MIN_SPEECH_PITCH + progress; + } + + /** + * Since we are appending the MIN_SPEECH_PITCH to the pitch seekbar progress, the pitch + * seekbar progress should be set to (pitchValue - MIN_SPEECH_PITCH). + */ + private int getPitchSeekBarProgressFromSpeechPitchValue(int pitchValue) { + return pitchValue - MIN_SPEECH_PITCH; + } + + /** * Called when the TTS engine is initialized. */ public void onInitEngine(int status) { @@ -484,9 +503,10 @@ public class TextToSpeechSettings extends SettingsPreferenceFragment implements @Override public boolean onPreferenceChange(Preference preference, Object objValue) { if (KEY_DEFAULT_RATE.equals(preference.getKey())) { - updateSpeechRate(((Integer) objValue).intValue()); + updateSpeechRate((Integer) objValue); } else if (KEY_DEFAULT_PITCH.equals(preference.getKey())) { - mDefaultPitch = ((Integer) objValue).intValue(); + int progress = (Integer) objValue; + mDefaultPitch = getSpeechPitchValueFromSeekBarProgress(progress); try { android.provider.Settings.Secure.putInt(getContentResolver(), TTS_DEFAULT_PITCH, mDefaultPitch); |