Browse Source

VoiceVariant.java: Use MALE and FEMALE string constants.

master
Reece H. Dunn 11 years ago
parent
commit
00bc5f2c6c

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

if (variantString == null) { if (variantString == null) {
final int gender = getPreferenceValue(prefs, "default_gender", SpeechSynthesis.GENDER_MALE); final int gender = getPreferenceValue(prefs, "default_gender", SpeechSynthesis.GENDER_MALE);
if (gender == SpeechSynthesis.GENDER_FEMALE) { if (gender == SpeechSynthesis.GENDER_FEMALE) {
variant = VoiceVariant.parseVoiceVariant("female");
variant = VoiceVariant.parseVoiceVariant(VoiceVariant.FEMALE);
} else { } else {
variant = VoiceVariant.parseVoiceVariant("male");
variant = VoiceVariant.parseVoiceVariant(VoiceVariant.MALE);
} }
} else { } else {
variant = VoiceVariant.parseVoiceVariant(variantString); variant = VoiceVariant.parseVoiceVariant(variantString);

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

if (variant == null) { if (variant == null) {
String gender = prefs.getString("default_gender", "0"); String gender = prefs.getString("default_gender", "0");
if (gender.equals("2")) { if (gender.equals("2")) {
editor.putString("espeak_variant", "female");
editor.putString("espeak_variant", VoiceVariant.FEMALE);
} else { } else {
editor.putString("espeak_variant", "male");
editor.putString("espeak_variant", VoiceVariant.MALE);
} }
} }



+ 7
- 4
android/src/com/reecedunn/espeak/VoiceVariant.java View File

public class VoiceVariant { public class VoiceVariant {
private static final Pattern mVariantPattern = Pattern.compile("-"); private static final Pattern mVariantPattern = Pattern.compile("-");


public static final String MALE = "male";
public static final String FEMALE = "female";

public final String variant; public final String variant;
public final int gender; public final int gender;
public final int age; public final int age;


protected VoiceVariant(String variant, int age) { protected VoiceVariant(String variant, int age) {
if (variant.equals("male")) {
if (variant.equals(MALE)) {
this.variant = null; this.variant = null;
this.gender = SpeechSynthesis.GENDER_MALE; this.gender = SpeechSynthesis.GENDER_MALE;
} else if (variant.equals("female")) {
} else if (variant.equals(FEMALE)) {
this.variant = null; this.variant = null;
this.gender = SpeechSynthesis.GENDER_FEMALE; this.gender = SpeechSynthesis.GENDER_FEMALE;
} else { } else {
public String toString() { public String toString() {
final String ret; final String ret;
if (gender == SpeechSynthesis.GENDER_MALE) { if (gender == SpeechSynthesis.GENDER_MALE) {
ret = "male";
ret = MALE;
} else if (gender == SpeechSynthesis.GENDER_FEMALE) { } else if (gender == SpeechSynthesis.GENDER_FEMALE) {
ret = "female";
ret = FEMALE;
} else { } else {
ret = variant; ret = variant;
} }

Loading…
Cancel
Save