Browse Source

Move the sample text logic into SpeechSynthesis.getSampleText and add test cases for it.

master
Reece H. Dunn 12 years ago
parent
commit
2a3a1a0a81

+ 22
- 1
android/eSpeakTests/src/com/reecedunn/espeak/test/SpeechSynthesisTest.java View File



package com.reecedunn.espeak.test; package com.reecedunn.espeak.test;


import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
assertThat(voice.match(eng_GBR_scotland), is(TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE)); assertThat(voice.match(eng_GBR_scotland), is(TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE));
assertThat(voice.match(eng_GBR_north), is(TextToSpeech.LANG_COUNTRY_AVAILABLE)); assertThat(voice.match(eng_GBR_north), is(TextToSpeech.LANG_COUNTRY_AVAILABLE));
} }

public void testGetSampleText()
{
for (VoiceData.Voice data : VoiceData.voices)
{
if (mRemoved.contains(data.name))
{
Log.i("SpeechSynthesisTest", "Skipping the missing voice '" + data.name + "'");
continue;
}

try
{
final Locale ianaLocale = new Locale(data.ianaLanguage, data.ianaCountry, data.variant);
assertThat(SpeechSynthesis.getSampleText(getContext(), ianaLocale), is(data.sampleText));
}
catch (AssertionError e)
{
throw new VoiceData.Exception(data, e);
}
}
}
} }

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

public final int gender; public final int gender;
public final String displayName; public final String displayName;
public final String locale; public final String locale;
public final String sampleText;


public Voice(String name, public Voice(String name,
String identifier, String identifier,
this.gender = gender; this.gender = gender;
this.displayName = displayName; this.displayName = displayName;
this.locale = locale; this.locale = locale;
this.sampleText = displayName;
} }


public Voice(String name, public Voice(String name,
this.gender = gender; this.gender = gender;
this.displayName = displayName; this.displayName = displayName;
this.locale = ianaLanguage; this.locale = ianaLanguage;
this.sampleText = displayName;
}

public Voice(String name,
String identifier,
String ianaLanguage,
String javaLanguage,
String ianaCountry,
String javaCountry,
String variant,
int gender,
String displayName,
String locale,
String sampleText)
{
this.name = name;
this.identifier = identifier;
this.ianaLanguage = ianaLanguage;
this.javaLanguage = javaLanguage;
this.ianaCountry = ianaCountry;
this.javaCountry = javaCountry;
this.variant = variant;
this.gender = gender;
this.displayName = displayName;
this.locale = locale;
this.sampleText = sampleText;
} }
} }


} }


public static final Voice[] voices = new Voice[] { public static final Voice[] voices = new Voice[] {
new Voice("af", "af", "af", "afr", "", "", "", SpeechSynthesis.GENDER_MALE, "Afrikaans"),
new Voice("ak", "test/ak", "ak", "aka", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Akan"),
new Voice("am", "test/am", "am", "amh", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Amharic"),
new Voice("az", "test/az", "az", "aze", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Azerbaijani"),
new Voice("bg", "test/bg", "bg", "bul", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Bulgarian"),
new Voice("bs", "bs", "bs", "bos", "", "", "", SpeechSynthesis.GENDER_MALE, "Bosnian"),
new Voice("ca", "ca", "ca", "cat", "", "", "", SpeechSynthesis.GENDER_MALE, "Catalan"),
new Voice("cs", "cs", "cs", "ces", "", "", "", SpeechSynthesis.GENDER_MALE, "Czech"),
new Voice("cy", "cy", "cy", "cym", "", "", "", SpeechSynthesis.GENDER_MALE, "Welsh"),
new Voice("da", "da", "da", "dan", "", "", "", SpeechSynthesis.GENDER_MALE, "Danish"),
new Voice("de", "de", "de", "deu", "", "", "", SpeechSynthesis.GENDER_MALE, "German"),
new Voice("dv", "test/dv", "dv", "div", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Divehi"),
new Voice("el", "el", "el", "ell", "", "", "", SpeechSynthesis.GENDER_MALE, "Greek (Modern)"),
new Voice("en", "default", "en", "eng", "", "", "", SpeechSynthesis.GENDER_MALE, "German"),
new Voice("en-sc", "en/en-sc", "en", "eng", "GB", "GBR", "scotland", SpeechSynthesis.GENDER_MALE, "English (Scotland)", "en-GB-scotland"),
new Voice("en-uk", "en/en", "en", "eng", "GB", "GBR", "", SpeechSynthesis.GENDER_MALE, "English (UK)", "en-GB"),
new Voice("en-uk-north", "en/en-n", "en", "eng", "GB", "GBR", "north", SpeechSynthesis.GENDER_MALE, "English (Lancashire)", "en-GB-north"),
new Voice("en-uk-rp", "en/en-rp", "en", "eng", "GB", "GBR", "rp", SpeechSynthesis.GENDER_MALE, "English (Received Pronunciation)", "en-GB-rp"),
new Voice("en-uk-wmids", "en/en-wm", "en", "eng", "GB", "GBR", "wmids", SpeechSynthesis.GENDER_MALE, "English (West Midlands)", "en-GB-wmids"),
new Voice("en-us", "en/en-us", "en", "eng", "US", "USA", "", SpeechSynthesis.GENDER_MALE, "English (US)", "en-US"),
new Voice("en-wi", "en/en-wi", "en", "eng", "029", "", "", SpeechSynthesis.GENDER_MALE, "English (Caribbean)", "en-029"),
new Voice("eo", "eo", "eo", "epo", "", "", "", SpeechSynthesis.GENDER_MALE, "Esperanto"),
new Voice("es", "es", "es", "spa", "", "", "", SpeechSynthesis.GENDER_MALE, "Spanish"),
new Voice("es-la", "es-la", "es", "spa", "419", "", "", SpeechSynthesis.GENDER_MALE, "Spanish (Latin America)", "es-419"),
new Voice("et", "et", "et", "est", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Estonian"),
new Voice("fi", "fi", "fi", "fin", "", "", "", SpeechSynthesis.GENDER_MALE, "Finnish"),
new Voice("fr-be", "fr-be", "fr", "fra", "BE", "BEL", "", SpeechSynthesis.GENDER_MALE, "French (Belgium)", "fr-BE"),
new Voice("fr-fr", "fr", "fr", "fra", "FR", "FRA", "", SpeechSynthesis.GENDER_MALE, "French (France)", "fr-FR"),
new Voice("ga", "test/ga", "ga", "gle", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Irish"),
new Voice("grc", "test/grc", "grc", "grc", "", "", "", SpeechSynthesis.GENDER_MALE, "Greek (Ancient)"),
new Voice("hi", "hi", "hi", "hin", "", "", "", SpeechSynthesis.GENDER_MALE, "Hindi"),
new Voice("hr", "hr", "hr", "hrv", "", "", "", SpeechSynthesis.GENDER_MALE, "Croatian"),
new Voice("ht", "test/ht", "ht", "hat", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Haitian Creole"),
new Voice("hu", "hu", "hu", "hun", "", "", "", SpeechSynthesis.GENDER_MALE, "Hungarian"),
new Voice("hy", "hy", "hy", "hye", "", "", "", SpeechSynthesis.GENDER_MALE, "Armenian"),
new Voice("hy-west", "hy-west", "hy", "hye", "", "", "arevmda", SpeechSynthesis.GENDER_MALE, "Armenian (Western)", "hy--arevmda"),
new Voice("id", "id", "in", "ind", "", "", "", SpeechSynthesis.GENDER_MALE, "Indonesia"),
new Voice("is", "is", "is", "isl", "", "", "", SpeechSynthesis.GENDER_MALE, "Icelandic"),
new Voice("it", "it", "it", "ita", "", "", "", SpeechSynthesis.GENDER_MALE, "Italian"),
new Voice("jbo", "test/jbo", "jbo", "jbo", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Lojban"),
new Voice("ka", "ka", "ka", "kat", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Georgian"),
new Voice("kk", "test/kk", "kk", "kaz", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Kazakh"),
new Voice("kl", "test/kl", "kl", "kal", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Greenlandic"),
new Voice("kn", "kn", "kn", "kan", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Kannada"),
new Voice("ko", "test/ko", "ko", "kor", "", "", "", SpeechSynthesis.GENDER_MALE, "Korean"),
new Voice("ku", "ku", "ku", "kur", "", "", "", SpeechSynthesis.GENDER_MALE, "Kurdish"),
new Voice("la", "la", "la", "lat", "", "", "", SpeechSynthesis.GENDER_MALE, "Latin"),
new Voice("lt", "test/lt", "lt", "lit", "", "", "", SpeechSynthesis.GENDER_MALE, "Lithuanian"),
new Voice("lv", "lv", "lv", "lav", "", "", "", SpeechSynthesis.GENDER_MALE, "Latvian"),
new Voice("mk", "mk", "mk", "mkd", "", "", "", SpeechSynthesis.GENDER_MALE, "Macedonian"),
new Voice("ml", "ml", "ml", "mal", "", "", "", SpeechSynthesis.GENDER_MALE, "Malayalam"),
new Voice("mt", "test/mt", "mt", "mlt", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Maltese"),
new Voice("nci", "test/nci", "nci", "", "", "", "", SpeechSynthesis.GENDER_MALE, "Classical Nahuatl"),
new Voice("ne", "test/ne", "ne", "nep", "", "", "", SpeechSynthesis.GENDER_MALE, "Nepali"),
new Voice("nl", "nl", "nl", "nld", "", "", "", SpeechSynthesis.GENDER_MALE, "Dutch"),
new Voice("no", "no", "no", "nor", "", "", "", SpeechSynthesis.GENDER_MALE, "Norwegian"),
new Voice("nso", "test/nso", "nso", "nso", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Sotho (Northern)"),
new Voice("pa", "test/pa", "pa", "pan", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Panjabi"),
new Voice("pap", "test/pap", "pap", "pap", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Papiamento"),
new Voice("pl", "pl", "pl", "pol", "", "", "", SpeechSynthesis.GENDER_MALE, "Polish"),
new Voice("prs", "test/prs", "prs", "", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Dari (Afghan Persian)"),
new Voice("pt-br", "pt", "pt", "por", "BR", "BRA", "", SpeechSynthesis.GENDER_MALE, "Portuguese (Brazil)", "pt-BR"),
new Voice("pt-pt", "pt-pt", "pt", "por", "PT", "PRT", "", SpeechSynthesis.GENDER_MALE, "Portuguese (Portugal)", "pt-PT"),
new Voice("ro", "ro", "ro", "ron", "", "", "", SpeechSynthesis.GENDER_MALE, "Romanian"),
new Voice("ru", "ru", "ru", "rus", "", "", "", SpeechSynthesis.GENDER_MALE, "Russian"),
new Voice("rw", "test/rw", "rw", "kin", "", "", "", SpeechSynthesis.GENDER_MALE, "Kinyarwanda"),
new Voice("si", "test/si", "si", "sin", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Sinhalese"),
new Voice("sk", "sk", "sk", "slk", "", "", "", SpeechSynthesis.GENDER_MALE, "Slovak"),
new Voice("sl", "test/sl", "sl", "slv", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Slovenian"),
new Voice("sq", "sq", "sq", "sqi", "", "", "", SpeechSynthesis.GENDER_MALE, "Albanian"),
new Voice("sr", "sr", "sr", "srp", "", "", "", SpeechSynthesis.GENDER_MALE, "Serbian"),
new Voice("sv", "sv", "sv", "swe", "", "", "", SpeechSynthesis.GENDER_MALE, "Swedish"),
new Voice("sw", "sw", "sw", "swa", "", "", "", SpeechSynthesis.GENDER_MALE, "Swahili"),
new Voice("ta", "ta", "ta", "tam", "", "", "", SpeechSynthesis.GENDER_MALE, "Tamil"),
new Voice("te", "test/te", "te", "tel", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Telugu"),
new Voice("tn", "test/tn", "tn", "tsn", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Setswana"),
new Voice("tr", "tr", "tr", "tur", "", "", "", SpeechSynthesis.GENDER_MALE, "Turkish"),
new Voice("tt", "test/tt", "tt", "tat", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Tatar"),
new Voice("ur", "test/ur", "ur", "urd", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Urdu"),
new Voice("vi", "vi", "vi", "vie", "", "", "", SpeechSynthesis.GENDER_MALE, "Vietnamese"),
new Voice("wo", "test/wo", "wo", "wol", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Wolof"),
new Voice("zh", "zh", "zh", "zho", "", "", "", SpeechSynthesis.GENDER_MALE, "Chinese (Mandarin)"),
new Voice("zh-yue", "zh-yue", "yue", "", "", "", "", SpeechSynthesis.GENDER_MALE, "Chinese (Cantonese)"),
new Voice("af", "af", "af", "afr", "", "", "", SpeechSynthesis.GENDER_MALE, "Afrikaans", "af", "Hierdie is 'n voorbeeld van gesproke teks in Afrikaans"),
new Voice("ak", "test/ak", "ak", "aka", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Akan", "ak", "This is a sample of text spoken in Akan"),
new Voice("am", "test/am", "am", "amh", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Amharic", "am", "ይሄ በአማርኛ ላይ የተነገረ ጽሑፍ ናሙና ነው።"),
new Voice("az", "test/az", "az", "aze", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Azerbaijani", "az", "This is a sample of text spoken in Azerbaijani"),
new Voice("bg", "test/bg", "bg", "bul", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Bulgarian", "bg", "Това е откъс от изговорен текст на български"),
new Voice("bs", "bs", "bs", "bos", "", "", "", SpeechSynthesis.GENDER_MALE, "Bosnian", "bs", "This is a sample of text spoken in Bosnian"),
new Voice("ca", "ca", "ca", "cat", "", "", "", SpeechSynthesis.GENDER_MALE, "Catalan", "ca", "Aquesta és una mostra de text dit en veu alta en català"),
new Voice("cs", "cs", "cs", "ces", "", "", "", SpeechSynthesis.GENDER_MALE, "Czech", "cs", "Toto je ukázkový text namluvený v jazyce čeština"),
new Voice("cy", "cy", "cy", "cym", "", "", "", SpeechSynthesis.GENDER_MALE, "Welsh", "cy", "This is a sample of text spoken in Welsh"),
new Voice("da", "da", "da", "dan", "", "", "", SpeechSynthesis.GENDER_MALE, "Danish", "da", "Dette er et eksempel på talt tekst på dansk"),
new Voice("de", "de", "de", "deu", "", "", "", SpeechSynthesis.GENDER_MALE, "German", "de", "Dies ist ein Beispieltext auf Deutsch."),
new Voice("dv", "test/dv", "dv", "div", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Divehi", "dv", "This is a sample of text spoken in Divehi"),
new Voice("el", "el", "el", "ell", "", "", "", SpeechSynthesis.GENDER_MALE, "Greek (Modern)", "el", "Αυτό είναι ένα δείγμα κειμένου που εκφέρεται στα Ελληνικά"),
new Voice("en", "default", "en", "eng", "", "", "", SpeechSynthesis.GENDER_MALE, "English", "en", "This is a sample of text spoken in English"),
new Voice("en-sc", "en/en-sc", "en", "eng", "GB", "GBR", "scotland", SpeechSynthesis.GENDER_MALE, "English (Scotland)", "en-GB-scotland", "This is a sample of text spoken in English (United Kingdom,Scottish Standard English)"),
new Voice("en-uk", "en/en", "en", "eng", "GB", "GBR", "", SpeechSynthesis.GENDER_MALE, "English (UK)", "en-GB", "This is a sample of text spoken in English (United Kingdom)"),
new Voice("en-uk-north", "en/en-n", "en", "eng", "GB", "GBR", "north", SpeechSynthesis.GENDER_MALE, "English (Lancashire)", "en-GB-north", "This is a sample of text spoken in English (United Kingdom,NORTH)"),
new Voice("en-uk-rp", "en/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", "en/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/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", "en/en-wi", "en", "eng", "029", "", "", SpeechSynthesis.GENDER_MALE, "English (Caribbean)", "en-029", "This is a sample of text spoken in English (Caribbean)"),
new Voice("eo", "eo", "eo", "epo", "", "", "", SpeechSynthesis.GENDER_MALE, "Esperanto", "eo", "This is a sample of text spoken in Esperanto"),
new Voice("es", "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 (Latinoamérica)."),
new Voice("et", "et", "et", "est", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Estonian", "et", "This is a sample of text spoken in eesti"),
new Voice("fi", "fi", "fi", "fin", "", "", "", SpeechSynthesis.GENDER_MALE, "Finnish", "fi", "Tämä on näyte kielellä suomi puhutusta tekstistä"),
new Voice("fr-be", "fr-be", "fr", "fra", "BE", "BEL", "", SpeechSynthesis.GENDER_MALE, "French (Belgium)", "fr-BE", "Voici un exemple de texte énoncé en français (Belgique)."),
new Voice("fr-fr", "fr", "fr", "fra", "FR", "FRA", "", SpeechSynthesis.GENDER_MALE, "French (France)", "fr-FR", "Voici un exemple de texte énoncé en français (France)."),
new Voice("ga", "test/ga", "ga", "gle", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Irish", "ga", "This is a sample of text spoken in Irish"),
new Voice("grc", "test/grc", "grc", "grc", "", "", "", SpeechSynthesis.GENDER_MALE, "Greek (Ancient)", "grc", "This is a sample of text spoken in Ancient Greek"),
new Voice("hi", "hi", "hi", "hin", "", "", "", SpeechSynthesis.GENDER_MALE, "Hindi", "hi", "यह हिन्दी में बोले गए पाठ का नमूना है"),
new Voice("hr", "hr", "hr", "hrv", "", "", "", SpeechSynthesis.GENDER_MALE, "Croatian", "hr", "Ovo je primjer teksta izgovorenog na hrvatski"),
new Voice("ht", "test/ht", "ht", "hat", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Haitian Creole", "ht", "This is a sample of text spoken in Haitian"),
new Voice("hu", "hu", "hu", "hun", "", "", "", SpeechSynthesis.GENDER_MALE, "Hungarian", "hu", "Ez egy magyar nyelven felolvasott szöveg mintája."),
new Voice("hy", "hy", "hy", "hye", "", "", "", SpeechSynthesis.GENDER_MALE, "Armenian", "hy", "This is a sample of text spoken in Armenian"),
new Voice("hy-west", "hy-west", "hy", "hye", "", "", "arevmda", SpeechSynthesis.GENDER_MALE, "Armenian (Western)", "hy--arevmda", "This is a sample of text spoken in Armenian (Western Armenian)"),
new Voice("id", "id", "in", "ind", "", "", "", SpeechSynthesis.GENDER_MALE, "Indonesia", "in", "Ini adalah contoh teks yang diucapkan di Bahasa Indonesia"), // NOTE: 'id' is the correct ISO 639-1 code, but Android/Java uses 'in'.
new Voice("is", "is", "is", "isl", "", "", "", SpeechSynthesis.GENDER_MALE, "Icelandic", "is", "This is a sample of text spoken in Icelandic"),
new Voice("it", "it", "it", "ita", "", "", "", SpeechSynthesis.GENDER_MALE, "Italian", "it", "Questo è un esempio di testo parlato in italiano"),
new Voice("jbo", "test/jbo", "jbo", "jbo", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Lojban", "jbo", "This is a sample of text spoken in Lojban"),
new Voice("ka", "ka", "ka", "kat", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Georgian", "ka", "This is a sample of text spoken in Georgian"),
new Voice("kk", "test/kk", "kk", "kaz", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Kazakh", "kk", "This is a sample of text spoken in Kazakh"),
new Voice("kl", "test/kl", "kl", "kal", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Greenlandic", "kl", "This is a sample of text spoken in Kalaallisut"),
new Voice("kn", "kn", "kn", "kan", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Kannada", "kn", "This is a sample of text spoken in Kannada"),
new Voice("ko", "test/ko", "ko", "kor", "", "", "", SpeechSynthesis.GENDER_MALE, "Korean", "ko", "한국어로 읽은 텍스트 샘플입니다."),
new Voice("ku", "ku", "ku", "kur", "", "", "", SpeechSynthesis.GENDER_MALE, "Kurdish", "ku", "This is a sample of text spoken in Kurdish"),
new Voice("la", "la", "la", "lat", "", "", "", SpeechSynthesis.GENDER_MALE, "Latin", "la", "This is a sample of text spoken in Latin"),
new Voice("lt", "test/lt", "lt", "lit", "", "", "", SpeechSynthesis.GENDER_MALE, "Lithuanian", "lt", "Tai teksto, sakomo lietuvių, pavyzdys"),
new Voice("lv", "lv", "lv", "lav", "", "", "", SpeechSynthesis.GENDER_MALE, "Latvian", "lv", "Šis ir izrunāta teksta paraugs šādā valodā: latviešu."),
new Voice("mk", "mk", "mk", "mkd", "", "", "", SpeechSynthesis.GENDER_MALE, "Macedonian", "mk", "This is a sample of text spoken in Macedonian"),
new Voice("ml", "ml", "ml", "mal", "", "", "", SpeechSynthesis.GENDER_MALE, "Malayalam", "ml", "This is a sample of text spoken in Malayalam"),
new Voice("mt", "test/mt", "mt", "mlt", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Maltese", "mt", "This is a sample of text spoken in Maltese"),
new Voice("nci", "test/nci", "nci", "", "", "", "", SpeechSynthesis.GENDER_MALE, "Classical Nahuatl", "nci", "This is a sample of text spoken in nci"),
new Voice("ne", "test/ne", "ne", "nep", "", "", "", SpeechSynthesis.GENDER_MALE, "Nepali", "ne", "This is a sample of text spoken in Nepali"),
new Voice("nl", "nl", "nl", "nld", "", "", "", SpeechSynthesis.GENDER_MALE, "Dutch", "nl", "Dit is een voorbeeld van tekst die is uitgesproken in het Nederlands"),
new Voice("no", "no", "no", "nor", "", "", "", SpeechSynthesis.GENDER_MALE, "Norwegian", "no", "This is a sample of text spoken in Norwegian"),
new Voice("nso", "test/nso", "nso", "nso", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Sotho (Northern)", "nso", "This is a sample of text spoken in Northern Sotho"),
new Voice("pa", "test/pa", "pa", "pan", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Panjabi", "pa", "This is a sample of text spoken in Punjabi"),
new Voice("pap", "test/pap", "pap", "pap", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Papiamento", "pap", "This is a sample of text spoken in Papiamento"),
new Voice("pl", "pl", "pl", "pol", "", "", "", SpeechSynthesis.GENDER_MALE, "Polish", "pl", "To jest przykład tekstu mówionego przy ustawieniu polski"),
new Voice("prs", "test/prs", "prs", "", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Dari (Afghan Persian)", "prs", "This is a sample of text spoken in prs"),
new Voice("pt-br", "pt", "pt", "por", "BR", "BRA", "", SpeechSynthesis.GENDER_MALE, "Portuguese (Brazil)", "pt-BR", "Este é um exemplo de texto falado em português (Brasil)"),
new Voice("pt-pt", "pt-pt", "pt", "por", "PT", "PRT", "", SpeechSynthesis.GENDER_MALE, "Portuguese (Portugal)", "pt-PT", "Este é um exemplo de texto falado em português (Portugal)"),
new Voice("ro", "ro", "ro", "ron", "", "", "", SpeechSynthesis.GENDER_MALE, "Romanian", "ro", "Aceasta este o mostră de text vorbit în română"),
new Voice("ru", "ru", "ru", "rus", "", "", "", SpeechSynthesis.GENDER_MALE, "Russian", "ru", "Так синтезатор речи озвучивает русский текст"),
new Voice("rw", "test/rw", "rw", "kin", "", "", "", SpeechSynthesis.GENDER_MALE, "Kinyarwanda", "rw", "This is a sample of text spoken in Kinyarwanda"),
new Voice("si", "test/si", "si", "sin", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Sinhalese", "si", "This is a sample of text spoken in Sinhala"),
new Voice("sk", "sk", "sk", "slk", "", "", "", SpeechSynthesis.GENDER_MALE, "Slovak", "sk", "Toto je ukážkový text nahovorený v jazyku slovenčina"),
new Voice("sl", "test/sl", "sl", "slv", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Slovenian", "sl", "To je vzorec besedila, izgovorjen v slovenščina"),
new Voice("sq", "sq", "sq", "sqi", "", "", "", SpeechSynthesis.GENDER_MALE, "Albanian", "sq", "This is a sample of text spoken in Albanian"),
new Voice("sr", "sr", "sr", "srp", "", "", "", SpeechSynthesis.GENDER_MALE, "Serbian", "sr", "Ово је пример текста који је изговорен на језику Српски"),
new Voice("sv", "sv", "sv", "swe", "", "", "", SpeechSynthesis.GENDER_MALE, "Swedish", "sv", "Detta är ett textexempel som läses på svenska"),
new Voice("sw", "sw", "sw", "swa", "", "", "", SpeechSynthesis.GENDER_MALE, "Swahili", "sw", "Hii ni sampuli ya maandishi yaliyonenwa katika Kiswahili"),
new Voice("ta", "ta", "ta", "tam", "", "", "", SpeechSynthesis.GENDER_MALE, "Tamil", "ta", "This is a sample of text spoken in Tamil"),
new Voice("te", "test/te", "te", "tel", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Telugu", "te", "This is a sample of text spoken in Telugu"),
new Voice("tn", "test/tn", "tn", "tsn", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Setswana", "tn", "This is a sample of text spoken in Tswana"),
new Voice("tr", "tr", "tr", "tur", "", "", "", SpeechSynthesis.GENDER_MALE, "Turkish", "tr", "Bu, Türkçe dilinde seslendirilen örnek bir metindir"),
new Voice("tt", "test/tt", "tt", "tat", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Tatar", "tt", "This is a sample of text spoken in Tatar"),
new Voice("ur", "test/ur", "ur", "urd", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Urdu", "ur", "This is a sample of text spoken in Urdu"),
new Voice("vi", "vi", "vi", "vie", "", "", "", SpeechSynthesis.GENDER_MALE, "Vietnamese", "vi", "Đây là mẫu văn bản được đọc bằng Tiếng Việt"),
new Voice("wo", "test/wo", "wo", "wol", "", "", "", SpeechSynthesis.GENDER_UNSPECIFIED, "Wolof", "wo", "This is a sample of text spoken in Wolof"),
new Voice("zh", "zh", "zh", "zho", "", "", "", SpeechSynthesis.GENDER_MALE, "Chinese (Mandarin)", "zh", "This is a sample of text spoken in 中文"),
new Voice("zh-yue", "zh-yue", "yue", "", "", "", "", SpeechSynthesis.GENDER_MALE, "Chinese (Cantonese)", "yue", "This is a sample of text spoken in Cantonese"),
}; };
} }

+ 0
- 35
android/res/values/donottranslate.xml View File

<item>2</item> <item>2</item>
</string-array> </string-array>


<string name="afr">haai</string>
<string name="bos">Zdravo</string>
<string name="zho">你好</string>
<string name="hrv">bok</string>
<string name="ces">ahoj</string>
<string name="nld">hallo</string>
<string name="eng">hello</string>
<string name="epo">saluton</string>
<string name="fin">hei</string>
<string name="fra">bonjour</string>
<string name="deu">hallo</string>
<string name="ell">γεια σου</string>
<string name="hin">नमस्ते</string>
<string name="hun">jo napot</string>
<string name="isl">góðan dag</string>
<string name="ind">halo</string>
<string name="ita">ciao</string>
<string name="kur">roj bahsh</string>
<string name="lat">salve</string>
<string name="mkd">Zdravo</string>
<string name="nor">hallo</string>
<string name="pol">witaj</string>
<string name="por">Olá</string>
<string name="ron">salut</string>
<string name="rus">привет</string>
<string name="srp">здраво</string>
<string name="slk">ahoj</string>
<string name="spa">hola</string>
<string name="swa">Jambo</string>
<string name="swe">hej</string>
<string name="tam">vanakkam</string>
<string name="tur">merhaba</string>
<string name="vie">xin chao</string>
<string name="cym">shwmae</string>

</resources> </resources>

+ 2
- 103
android/src/com/reecedunn/espeak/GetSampleText.java View File

/* /*
* Copyright (C) 2012 Reece H. Dunn
* Copyright (C) 2011 The Android Open Source Project * Copyright (C) 2011 The Android Open Source Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");


import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.Resources.NotFoundException;
import android.os.Bundle; import android.os.Bundle;
import android.speech.tts.TextToSpeech; import android.speech.tts.TextToSpeech;
import android.util.DisplayMetrics;
import android.util.Log;


import java.util.Locale; import java.util.Locale;


* Returns the sample text string for the language requested * Returns the sample text string for the language requested
*/ */
public class GetSampleText extends Activity { public class GetSampleText extends Activity {
private static final String TAG = GetSampleText.class.getSimpleName();

@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);


final Locale locale = getLocaleFromIntent(getIntent()); final Locale locale = getLocaleFromIntent(getIntent());
final Resources res = getResourcesForLocale(this, locale);

String text = null;

try {
text = res.getString(R.string.sample_text, locale.getDisplayName(locale));
} catch (NotFoundException e) {
e.printStackTrace();
}

final String language = (locale == null) ? "eng" : locale.getISO3Language();

if (text != null) {
// Do nothing.
} else if (language.equals("afr")) {
text = getString(R.string.afr);
} else if (language.equals("bos")) {
text = getString(R.string.bos);
} else if (language.equals("zho")) {
text = getString(R.string.zho);
} else if (language.equals("hrv")) {
text = getString(R.string.hrv);
} else if (language.equals("ces")) {
text = getString(R.string.ces);
} else if (language.equals("nld")) {
text = getString(R.string.nld);
} else if (language.equals("eng")) {
text = getString(R.string.eng);
} else if (language.equals("epo")) {
text = getString(R.string.epo);
} else if (language.equals("fin")) {
text = getString(R.string.fin);
} else if (language.equals("fra")) {
text = getString(R.string.fra);
} else if (language.equals("deu")) {
text = getString(R.string.deu);
} else if (language.equals("ell")) {
text = getString(R.string.ell);
} else if (language.equals("hin")) {
text = getString(R.string.hin);
} else if (language.equals("hun")) {
text = getString(R.string.hun);
} else if (language.equals("isl")) {
text = getString(R.string.isl);
} else if (language.equals("ind")) {
text = getString(R.string.ind);
} else if (language.equals("ita")) {
text = getString(R.string.ita);
} else if (language.equals("kur")) {
text = getString(R.string.kur);
} else if (language.equals("lat")) {
text = getString(R.string.lat);
} else if (language.equals("mkd")) {
text = getString(R.string.mkd);
} else if (language.equals("nor")) {
text = getString(R.string.nor);
} else if (language.equals("pol")) {
text = getString(R.string.pol);
} else if (language.equals("por")) {
text = getString(R.string.por);
} else if (language.equals("ron")) {
text = getString(R.string.ron);
} else if (language.equals("rus")) {
text = getString(R.string.rus);
} else if (language.equals("srp")) {
text = getString(R.string.srp);
} else if (language.equals("slk")) {
text = getString(R.string.slk);
} else if (language.equals("spa")) {
text = getString(R.string.spa);
} else if (language.equals("swa")) {
text = getString(R.string.swa);
} else if (language.equals("swe")) {
text = getString(R.string.swe);
} else if (language.equals("tam")) {
text = getString(R.string.tam);
} else if (language.equals("tur")) {
text = getString(R.string.tur);
} else if (language.equals("vie")) {
text = getString(R.string.vie);
} else if (language.equals("cym")) {
text = getString(R.string.cym);
} else {
Log.e(TAG, "Missing sample text for " + language);
text = getString(R.string.eng);
}
final String text = SpeechSynthesis.getSampleText(getBaseContext(), locale);


final int result = TextToSpeech.LANG_AVAILABLE; final int result = TextToSpeech.LANG_AVAILABLE;
final Intent returnData = new Intent(); final Intent returnData = new Intent();


return Locale.getDefault(); return Locale.getDefault();
} }

private static Resources getResourcesForLocale(Activity activity, Locale locale) {
final Configuration config = activity.getResources().getConfiguration();
config.locale = locale;

final DisplayMetrics metrics = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);

return new Resources(activity.getAssets(), metrics, config);
}
} }

+ 13
- 0
android/src/com/reecedunn/espeak/SpeechSynthesis.java View File

/* /*
* Copyright (C) 2012 Reece H. Dunn
* Copyright (C) 2011 Google Inc. * Copyright (C) 2011 Google Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
package com.reecedunn.espeak; package com.reecedunn.espeak;


import android.content.Context; import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.speech.tts.TextToSpeech; import android.speech.tts.TextToSpeech;
import android.util.DisplayMetrics;
import android.util.Log; import android.util.Log;


import java.io.File; import java.io.File;
mInitialized = true; mInitialized = true;
} }


public static String getSampleText(Context context, Locale locale) {
final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
final Configuration config = context.getResources().getConfiguration();
config.locale = locale;

Resources res = new Resources(context.getAssets(), metrics, config);
return res.getString(R.string.sample_text, locale.getDisplayName(locale));
}

private int mNativeData; private int mNativeData;


private static native final boolean nativeClassInit(); private static native final boolean nativeClassInit();

Loading…
Cancel
Save