String id;
// Is there a match by voice name? If yes, return it.
// Otherwise, ignore name.
if (name != null && name.length() > 0) {
id = getVoiceId(new Voice(name,
Voice.GENDER_DONT_CARE,
Voice.AGE_DONT_CARE,
null),
0);
if (id != null && id.length() > 0) {
return id;
}
}
// Try to match gender and age
id = getVoiceId(new Voice(null,
gender,
age,
null),
variant);
if (id != null && id.length() > 0) {
return id;
}
// Try to match gender and adjoining ages
int looseAge = age | (age << 1) | (age >> 1);
id = getVoiceId(new Voice(null,
gender,
looseAge,
null),
variant);
if (id != null && id.length() > 0) {
return id;
}
// Try to match just gender
id = getVoiceId(new Voice(null,
gender,
Voice.AGE_DONT_CARE,
null),
variant);
if (id != null && id.length() > 0) {