mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-12-03 06:55:44 +00:00
Use API 21.
This commit is contained in:
@@ -30,11 +30,11 @@ public class TextToSpeechTest extends TextToSpeechTestCase
|
||||
{
|
||||
assertThat(getEngine(), is(notNullValue()));
|
||||
|
||||
Locale initialLocale = getEngine().getLanguage();
|
||||
Locale initialLocale = getLanguage(getEngine());
|
||||
assertThat(getEngine().isLanguageAvailable(new Locale("cel")), isTtsLangCode(TextToSpeech.LANG_NOT_SUPPORTED));
|
||||
assertThat(getEngine().getLanguage().getLanguage(), is(initialLocale.getLanguage()));
|
||||
assertThat(getEngine().getLanguage().getCountry(), is(initialLocale.getCountry()));
|
||||
assertThat(getEngine().getLanguage().getVariant(), is(initialLocale.getVariant()));
|
||||
assertThat(getLanguage(getEngine()).getLanguage(), is(initialLocale.getLanguage()));
|
||||
assertThat(getLanguage(getEngine()).getCountry(), is(initialLocale.getCountry()));
|
||||
assertThat(getLanguage(getEngine()).getVariant(), is(initialLocale.getVariant()));
|
||||
}
|
||||
|
||||
public void testLanguages()
|
||||
@@ -60,44 +60,44 @@ public class TextToSpeechTest extends TextToSpeechTestCase
|
||||
context = "iana1";
|
||||
assertThat(getEngine().isLanguageAvailable(iana1), isTtsLangCode(TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE));
|
||||
assertThat(getEngine().setLanguage(iana1), isTtsLangCode(TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE));
|
||||
assertThat(getEngine().getLanguage().getLanguage(), is(data.javaLanguage));
|
||||
assertThat(getEngine().getLanguage().getCountry(), is(data.javaCountry));
|
||||
assertThat(getEngine().getLanguage().getVariant(), is(data.variant));
|
||||
assertThat(getLanguage(getEngine()).getLanguage(), is(data.javaLanguage));
|
||||
assertThat(getLanguage(getEngine()).getCountry(), is(data.javaCountry));
|
||||
assertThat(getLanguage(getEngine()).getVariant(), is(data.variant));
|
||||
|
||||
context = "iana2";
|
||||
assertThat(getEngine().isLanguageAvailable(iana2), isTtsLangCode(TextToSpeech.LANG_COUNTRY_AVAILABLE));
|
||||
assertThat(getEngine().setLanguage(iana2), isTtsLangCode(TextToSpeech.LANG_COUNTRY_AVAILABLE));
|
||||
assertThat(getEngine().getLanguage().getLanguage(), is(data.javaLanguage));
|
||||
assertThat(getEngine().getLanguage().getCountry(), is(data.javaCountry));
|
||||
assertThat(getEngine().getLanguage().getVariant(), is(""));
|
||||
assertThat(getLanguage(getEngine()).getLanguage(), is(data.javaLanguage));
|
||||
assertThat(getLanguage(getEngine()).getCountry(), is(data.javaCountry));
|
||||
assertThat(getLanguage(getEngine()).getVariant(), is(""));
|
||||
|
||||
context = "iana3";
|
||||
assertThat(getEngine().isLanguageAvailable(iana3), isTtsLangCode(TextToSpeech.LANG_AVAILABLE));
|
||||
assertThat(getEngine().setLanguage(iana3), isTtsLangCode(TextToSpeech.LANG_AVAILABLE));
|
||||
assertThat(getEngine().getLanguage().getLanguage(), is(data.javaLanguage));
|
||||
assertThat(getEngine().getLanguage().getCountry(), is(""));
|
||||
assertThat(getEngine().getLanguage().getVariant(), is(""));
|
||||
assertThat(getLanguage(getEngine()).getLanguage(), is(data.javaLanguage));
|
||||
assertThat(getLanguage(getEngine()).getCountry(), is(""));
|
||||
assertThat(getLanguage(getEngine()).getVariant(), is(""));
|
||||
|
||||
context = "java1";
|
||||
assertThat(getEngine().isLanguageAvailable(java1), isTtsLangCode(TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE));
|
||||
assertThat(getEngine().setLanguage(java1), isTtsLangCode(TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE));
|
||||
assertThat(getEngine().getLanguage().getLanguage(), is(data.javaLanguage));
|
||||
assertThat(getEngine().getLanguage().getCountry(), is(data.javaCountry));
|
||||
assertThat(getEngine().getLanguage().getVariant(), is(data.variant));
|
||||
assertThat(getLanguage(getEngine()).getLanguage(), is(data.javaLanguage));
|
||||
assertThat(getLanguage(getEngine()).getCountry(), is(data.javaCountry));
|
||||
assertThat(getLanguage(getEngine()).getVariant(), is(data.variant));
|
||||
|
||||
context = "java2";
|
||||
assertThat(getEngine().isLanguageAvailable(java2), isTtsLangCode(TextToSpeech.LANG_COUNTRY_AVAILABLE));
|
||||
assertThat(getEngine().setLanguage(java2), isTtsLangCode(TextToSpeech.LANG_COUNTRY_AVAILABLE));
|
||||
assertThat(getEngine().getLanguage().getLanguage(), is(data.javaLanguage));
|
||||
assertThat(getEngine().getLanguage().getCountry(), is(data.javaCountry));
|
||||
assertThat(getEngine().getLanguage().getVariant(), is(""));
|
||||
assertThat(getLanguage(getEngine()).getLanguage(), is(data.javaLanguage));
|
||||
assertThat(getLanguage(getEngine()).getCountry(), is(data.javaCountry));
|
||||
assertThat(getLanguage(getEngine()).getVariant(), is(""));
|
||||
|
||||
context = "java3";
|
||||
assertThat(getEngine().isLanguageAvailable(java3), isTtsLangCode(TextToSpeech.LANG_AVAILABLE));
|
||||
assertThat(getEngine().setLanguage(java3), isTtsLangCode(TextToSpeech.LANG_AVAILABLE));
|
||||
assertThat(getEngine().getLanguage().getLanguage(), is(data.javaLanguage));
|
||||
assertThat(getEngine().getLanguage().getCountry(), is(""));
|
||||
assertThat(getEngine().getLanguage().getVariant(), is(""));
|
||||
assertThat(getLanguage(getEngine()).getLanguage(), is(data.javaLanguage));
|
||||
assertThat(getLanguage(getEngine()).getCountry(), is(""));
|
||||
assertThat(getLanguage(getEngine()).getVariant(), is(""));
|
||||
}
|
||||
catch (AssertionError e)
|
||||
{
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.reecedunn.espeak.test;
|
||||
|
||||
import android.os.Build;
|
||||
import android.speech.tts.TextToSpeech;
|
||||
import android.speech.tts.TextToSpeech.OnInitListener;
|
||||
import android.test.AndroidTestCase;
|
||||
@@ -93,4 +94,19 @@ public class TextToSpeechTestCase extends AndroidTestCase
|
||||
{
|
||||
return mEngine;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static Locale getLanguage(TextToSpeech engine) {
|
||||
if (engine != null) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
android.speech.tts.Voice voice = engine.getVoice();
|
||||
if (voice != null) {
|
||||
return voice.getLocale();
|
||||
}
|
||||
} else {
|
||||
return engine.getLanguage();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user