Browse Source

Use en-JM instead of en-029 and es-MX instead of es-419.

Android does not support UN M.49 territory codes. Instead:
  *  4.2 and earlier return an empty string;
  *  4.3 throws a MissingResourceException.
master
Reece H. Dunn 12 years ago
parent
commit
d6308605de

+ 2
- 2
android/eSpeakTests/src/com/reecedunn/espeak/test/TextToSpeechTestCase.java View File

@@ -47,10 +47,10 @@ public class TextToSpeechTestCase extends AndroidTestCase
{
try
{
// Wait until the text-to-speech engine is initialised (max: 5 seconds):
// Wait until the text-to-speech engine is initialised (max: 20 seconds):

mEngine = new TextToSpeech(getContext(), mInitCallback);
for (int count = 0; !mInitialised && count < 20; ++count)
for (int count = 0; !mInitialised && count < (4 * 20); ++count)
{
Thread.sleep(250);
}

+ 3
- 3
android/eSpeakTests/src/com/reecedunn/espeak/test/VoiceData.java View File

@@ -120,10 +120,10 @@ public class VoiceData
new Voice("en-uk-rp", "other/en-rp", "en", "eng", "GB", "GBR", "rp", SpeechSynthesis.GENDER_MALE, "English (Received Pronunciation)", "en-GB-rp", "This is a sample of text spoken in English (United Kingdom,RP)"),
new Voice("en-uk-wmids", "other/en-wm", "en", "eng", "GB", "GBR", "wmids", SpeechSynthesis.GENDER_MALE, "English (West Midlands)", "en-GB-wmids", "This is a sample of text spoken in English (United Kingdom,WMIDS)"),
new Voice("en-us", "en-us", "en", "eng", "US", "USA", "", SpeechSynthesis.GENDER_MALE, "English (US)", "en-US", "This is a sample of text spoken in English (United States)"),
new Voice("en-wi", "other/en-wi", "en", "eng", "029", "", "", SpeechSynthesis.GENDER_MALE, "English (Caribbean)", "en-029", "This is a sample of text spoken in English"),
new Voice("en-wi", "other/en-wi", "en", "eng", "JM", "JAM", "", SpeechSynthesis.GENDER_MALE, "English (Caribbean)", "en-JM", "This is a sample of text spoken in English (Jamaica)"),
new Voice("eo", "other/eo", "eo", "epo", "", "", "", SpeechSynthesis.GENDER_MALE, "Esperanto", "eo", "This is a sample of text spoken in Esperanto"),
new Voice("es", "europe/es", "es", "spa", "", "", "", SpeechSynthesis.GENDER_MALE, "Spanish", "es", "Esto es un ejemplo de texto hablado en español."),
new Voice("es-la", "es-la", "es", "spa", "419", "", "", SpeechSynthesis.GENDER_MALE, "Spanish (Latin America)", "es-419", "Esto es un ejemplo de texto hablado en español."),
new Voice("es-la", "es-la", "es", "spa", "MX", "MEX", "", SpeechSynthesis.GENDER_MALE, "Spanish (Latin America)", "es-MX", "Esto es un ejemplo de texto hablado en español (México)."),
new Voice("et", "europe/et", "et", "est", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Estonian", "et", "This is a sample of text spoken in eesti", "This is a sample of text spoken in Estonian"),
new Voice("fa", "asia/fa", "fa", "fas", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Farsi (Persian)", "fa", "این یک نمونه از نوشتار گفته شده در فارسی است"),
new Voice("fi", "europe/fi", "fi", "fin", "", "", "", SpeechSynthesis.GENDER_MALE, "Finnish", "fi", "Tämä on näyte kielellä suomi puhutusta tekstistä"),
@@ -176,6 +176,6 @@ public class VoiceData
new Voice("vi-hue", "asia/vi-hue", "vi", "vie", "VN", "VNM", "hue", SpeechSynthesis.GENDER_MALE, "Vietnamese", "vi-VN-hue", "Đây là mẫu văn bản được đọc bằng Tiếng Việt (Việt Nam,HUE)"),
new Voice("vi-sgn", "asia/vi-sgn", "vi", "vie", "VN", "VNM", "saigon", SpeechSynthesis.GENDER_MALE, "Vietnamese", "vi-VN-saigon", "Đây là mẫu văn bản được đọc bằng Tiếng Việt (Việt Nam,SAIGON)"),
new Voice("zh", "asia/zh", "zh", "zho", "", "", "", SpeechSynthesis.GENDER_MALE, "Chinese (Mandarin)", "zh", "This is a sample of text spoken in 中文"),
new Voice("zh-yue", "asia/zh-yue", "zh", "zho", "HK", "HKG", "", SpeechSynthesis.GENDER_MALE, "Chinese (Cantonese)", "zh-HK", "This is a sample of text spoken in 中文 (中華人民共和國香港特別行政區)"),
new Voice("zh-yue", "asia/zh-yue", "zh", "zho", "HK", "HKG", "", SpeechSynthesis.GENDER_MALE, "Chinese (Cantonese)", "zh-HK", "This is a sample of text spoken in 中文 (中華人民共和國香港特別行政區)", "This is a sample of text spoken in 中文 (香港)"),
};
}

+ 8
- 11
android/src/com/reecedunn/espeak/SpeechSynthesis.java View File

@@ -124,11 +124,13 @@ public class SpeechSynthesis {
// 'SC' is not a country code.
locale = new Locale("en", "GB", "scotland");
} else if (name.equals("en-wi")) {
// 'WI' is not a country code.
locale = new Locale("en", "029");
// 'WI' is not a country code. Also, territory code 029 (Caribbean)
// is not supported by Android.
locale = new Locale("en", "JM");
} else if (name.equals("es-la")) {
// 'LA' is the country code for Laos, not Latin America.
locale = new Locale("es", "419");
// 'LA' is the country code for Laos, not Latin America. Also, territory code 419
// (Latin America) is not supported by Android.
locale = new Locale("es", "MX");
} else if (name.equals("hy-west")) {
// 'west' is not a country code.
locale = new Locale("hy", "", "arevmda");
@@ -168,11 +170,6 @@ public class SpeechSynthesis {

try {
if (locale != null && !locale.getISO3Language().equals("")) {
// This will throw a MissingResourceException on Android 4.3,
// so check here to avoid the exception in the Android
// TextToSpeech class.
String country = locale.getISO3Country();

final Voice voice = new Voice(name, identifier, gender, age, locale);
voices.add(voice);
}
@@ -438,8 +435,8 @@ public class SpeechSynthesis {
mJavaToIanaLanguageCode.put("zho", "zh");
mJavaToIanaLanguageCode.put("yue", "zh");

mJavaToIanaCountryCode.put("029", ""); // Locale.getCountry() does not map numeric country codes.
mJavaToIanaCountryCode.put("419", ""); // Locale.getCountry() does not map numeric country codes.
mJavaToIanaCountryCode.put("JAM", "JM");
mJavaToIanaCountryCode.put("MEX", "MX");
mJavaToIanaCountryCode.put("BEL", "BE");
mJavaToIanaCountryCode.put("BRA", "BR");
mJavaToIanaCountryCode.put("FRA", "FR");

Loading…
Cancel
Save