mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-07 23:31:26 +00:00
SpeechSynthesis: factor out the VoiceVariant class into its own file.
This commit is contained in:
@@ -345,59 +345,6 @@ public class SpeechSynthesis {
|
||||
void onSynthDataComplete();
|
||||
}
|
||||
|
||||
public static class VoiceVariant {
|
||||
public final String variant;
|
||||
public final int gender;
|
||||
public final int age;
|
||||
|
||||
protected VoiceVariant(String variant, int age) {
|
||||
if (variant.equals("male")) {
|
||||
this.variant = null;
|
||||
this.gender = GENDER_MALE;
|
||||
} else if (variant.equals("female")) {
|
||||
this.variant = null;
|
||||
this.gender = GENDER_FEMALE;
|
||||
} else {
|
||||
this.variant = variant;
|
||||
this.gender = GENDER_UNSPECIFIED;
|
||||
}
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final String ret;
|
||||
if (gender == GENDER_MALE) {
|
||||
ret = "male";
|
||||
} else if (gender == GENDER_FEMALE) {
|
||||
ret = "female";
|
||||
} else {
|
||||
ret = variant;
|
||||
}
|
||||
if (age == AGE_YOUNG) {
|
||||
return ret + "-young";
|
||||
} else if (age == AGE_OLD) {
|
||||
return ret + "-old";
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public static VoiceVariant parseVoiceVariant(String value) {
|
||||
String[] parts = value.split("-");
|
||||
int age = AGE_ANY;
|
||||
switch (parts.length) {
|
||||
case 1: // variant
|
||||
break;
|
||||
case 2: // variant-age
|
||||
age = parts[1].equals("young") ? AGE_YOUNG : AGE_OLD;
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return new VoiceVariant(parts[0], age);
|
||||
}
|
||||
|
||||
public class Voice {
|
||||
public final String name;
|
||||
public final String identifier;
|
||||
|
||||
Reference in New Issue
Block a user