Browse Source

Use BCP 47 locale codes for Voice.getLocale() to support the correct localization on Lollipop and later.

master
Reece H. Dunn 9 years ago
parent
commit
bb3b7e9a00

+ 4
- 4
android/eSpeakTests/src/com/reecedunn/espeak/test/TextToSpeechTest.java View File



assertThat(data, is(notNullValue())); assertThat(data, is(notNullValue()));
assertThat(voice.getName(), is(data.name)); assertThat(voice.getName(), is(data.name));
assertThat(voice.getLocale().getLanguage(), is(data.javaLanguage));
assertThat(voice.getLocale().getCountry(), is(data.javaCountry));
assertThat(voice.getLocale().getLanguage(), is(data.ianaLanguage));
assertThat(voice.getLocale().getCountry(), is(data.ianaCountry));
assertThat(voice.getLocale().getVariant(), is(data.variant)); assertThat(voice.getLocale().getVariant(), is(data.variant));
assertThat(voice.getFeatures(), is(notNullValue())); assertThat(voice.getFeatures(), is(notNullValue()));
assertThat(voice.getFeatures().size(), is(0)); assertThat(voice.getFeatures().size(), is(0));
android.speech.tts.Voice voice2 = getEngine().getVoice(); android.speech.tts.Voice voice2 = getEngine().getVoice();
assertThat(voice2, is(notNullValue())); assertThat(voice2, is(notNullValue()));
assertThat(voice2.getName(), is(data.name)); assertThat(voice2.getName(), is(data.name));
assertThat(voice2.getLocale().getLanguage(), is(data.javaLanguage));
assertThat(voice2.getLocale().getCountry(), is(data.javaCountry));
assertThat(voice2.getLocale().getLanguage(), is(data.ianaLanguage));
assertThat(voice2.getLocale().getCountry(), is(data.ianaCountry));
assertThat(voice2.getLocale().getVariant(), is(data.variant)); assertThat(voice2.getLocale().getVariant(), is(data.variant));
assertThat(voice2.getFeatures(), is(notNullValue())); assertThat(voice2.getFeatures(), is(notNullValue()));
assertThat(voice2.getFeatures().size(), is(0)); assertThat(voice2.getFeatures().size(), is(0));

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

int latency = android.speech.tts.Voice.LATENCY_VERY_LOW; int latency = android.speech.tts.Voice.LATENCY_VERY_LOW;
Locale locale = new Locale(voice.locale.getISO3Language(), voice.locale.getISO3Country(), voice.locale.getVariant()); Locale locale = new Locale(voice.locale.getISO3Language(), voice.locale.getISO3Country(), voice.locale.getVariant());
Set<String> features = onGetFeaturesForLanguage(locale.getLanguage(), locale.getCountry(), locale.getVariant()); Set<String> features = onGetFeaturesForLanguage(locale.getLanguage(), locale.getCountry(), locale.getVariant());
voices.add(new android.speech.tts.Voice(voice.name, locale, quality, latency, false, features));
voices.add(new android.speech.tts.Voice(voice.name, voice.locale, quality, latency, false, features));
} }
return voices; return voices;
} }

Loading…
Cancel
Save