Improve TTS initiatlization
This commit is contained in:
parent
eb56c19cf1
commit
9481a959cb
1 changed files with 10 additions and 3 deletions
|
@ -191,11 +191,18 @@ public class TTSCommandPlayerImpl extends AbstractPrologCommandPlayer {
|
||||||
final float speechRate = cSpeechRate;
|
final float speechRate = cSpeechRate;
|
||||||
|
|
||||||
final String[] lsplit = (language + "____.").split("[\\_\\-]");
|
final String[] lsplit = (language + "____.").split("[\\_\\-]");
|
||||||
// constructor supports lang_country_variant
|
// constructor supports 'lang-country-variant'
|
||||||
Locale newLocale0 = new Locale(lsplit[0], lsplit[1], lsplit[2]);
|
Locale newLocale0 = new Locale(lsplit[0]);
|
||||||
// #3344: Try Locale builder instead of constructor (only available from API 21). Also supports script (for now supported as trailing x_x_x_Scrp)
|
try {
|
||||||
|
newLocale0 = new Locale(lsplit[0], lsplit[1]);
|
||||||
|
newLocale0 = new Locale(lsplit[0], lsplit[1], lsplit[2]);
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
// Falls back to language only
|
||||||
|
}
|
||||||
|
// #3344: Try Locale builder instead of constructor (only available from API 21). Also supports script (for now supported as trailing 'l-c-v-Scrp')
|
||||||
if (android.os.Build.VERSION.SDK_INT >= 21) {
|
if (android.os.Build.VERSION.SDK_INT >= 21) {
|
||||||
try {
|
try {
|
||||||
|
newLocale0 = new Locale.Builder().setLanguage(lsplit[0]).setScript(lsplit[3]).setRegion(lsplit[1]).build();
|
||||||
newLocale0 = new Locale.Builder().setLanguage(lsplit[0]).setScript(lsplit[3]).setRegion(lsplit[1]).setVariant(lsplit[2]).build();
|
newLocale0 = new Locale.Builder().setLanguage(lsplit[0]).setScript(lsplit[3]).setRegion(lsplit[1]).setVariant(lsplit[2]).build();
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
// Falls back to constructor
|
// Falls back to constructor
|
||||||
|
|
Loading…
Reference in a new issue