Browse Source

Display the formatted units on the volume setting.

master
Reece H. Dunn 12 years ago
parent
commit
b60ed6c9ae

+ 2
- 0
android/res/values/strings.xml View File

<string name="ssml">Load SSML Template</string> <string name="ssml">Load SSML Template</string>
<string name="synthesis_demo">Enter text to speak:</string> <string name="synthesis_demo">Enter text to speak:</string>
<string name="espeak_volume">Volume</string> <string name="espeak_volume">Volume</string>
<string name="formatter_wpm">%s WPM</string>
<string name="formatter_percentage">%s%%</string>


</resources> </resources>

+ 24
- 11
android/src/com/reecedunn/espeak/SpeechSynthesis.java View File

/** Announce some of the punctuation characters. */ /** Announce some of the punctuation characters. */
public static int PUNCT_SOME = 2; public static int PUNCT_SOME = 2;


public enum UnitType {
Percentage,
WordsPerMinute,
/** One of the PUNCT_* constants. */
Punctuation,
}

public class Parameter { public class Parameter {
private final int id; private final int id;
private final int min; private final int min;
private final int max; private final int max;
private final UnitType unitType;


private Parameter(int id, int min, int max) {
private Parameter(int id, int min, int max, UnitType unitType) {
this.id = id; this.id = id;
this.min = min; this.min = min;
this.max = max; this.max = max;
this.unitType = unitType;
} }


public int getMinValue() { public int getMinValue() {
public void setValue(int value) { public void setValue(int value) {
nativeSetParameter(id, value); nativeSetParameter(id, value);
} }

public UnitType getUnitType() {
return unitType;
}
} }


/** Speech rate in words per minute. */
public final Parameter Rate = new Parameter(1, 80, 450);
/** Speech rate. */
public final Parameter Rate = new Parameter(1, 80, 450, UnitType.WordsPerMinute);


/** Audio volume in percent. */
public final Parameter Volume = new Parameter(2, 0, 200);
/** Audio volume. */
public final Parameter Volume = new Parameter(2, 0, 200, UnitType.Percentage);


/** Base pitch in percent. */
public final Parameter Pitch = new Parameter(3, 0, 100);
/** Base pitch. */
public final Parameter Pitch = new Parameter(3, 0, 100, UnitType.Percentage);


/** Pitch range in percent (monotone = 0). */
public final Parameter PitchRange = new Parameter(4, 0, 100);
/** Pitch range (monotone = 0). */
public final Parameter PitchRange = new Parameter(4, 0, 100, UnitType.Percentage);


/** Which punctuation characters to announce; see the PUNCT_* constants. */
public final Parameter Punctuation = new Parameter(5, 0, 2);
/** Which punctuation characters to announce. */
public final Parameter Punctuation = new Parameter(5, 0, 2, UnitType.Punctuation);


public void synthesize(String text, boolean isSsml) { public void synthesize(String text, boolean isSsml) {
nativeSynthesize(text, isSsml); nativeSynthesize(text, isSsml);

+ 15
- 2
android/src/com/reecedunn/espeak/TtsSettingsActivity.java View File

pref.setOnPreferenceChangeListener(mOnPreferenceChanged); pref.setOnPreferenceChangeListener(mOnPreferenceChanged);
pref.setPersistent(true); pref.setPersistent(true);


switch (parameter.getUnitType())
{
case Percentage:
pref.getExtras().putString("formatter", context.getString(R.string.formatter_percentage));
break;
case WordsPerMinute:
pref.getExtras().putString("formatter", context.getString(R.string.formatter_wpm));
break;
default:
throw new IllegalStateException("Unsupported unit type for the parameter.");
}

pref.setMin(parameter.getMinValue()); pref.setMin(parameter.getMinValue());
pref.setMax(parameter.getMaxValue()); pref.setMax(parameter.getMaxValue());


summary = entries[index].toString(); summary = entries[index].toString();
} }
} else if (preference instanceof SeekBarPreference) { } else if (preference instanceof SeekBarPreference) {
summary = (String)newValue;
String formatter = preference.getExtras().getString("formatter");
summary = String.format(formatter, (String)newValue);
} }
preference.setSummary(summary.replaceAll("%", "%%"));
preference.setSummary(summary);
} }
return true; return true;
} }

Loading…
Cancel
Save