| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
package com.reecedunn.espeak; |
| 19 |
|
| 20 |
import java.util.Locale; |
| 21 |
import java.util.MissingResourceException; |
| 22 |
|
| 23 |
import android.speech.tts.TextToSpeech; |
| 24 |
|
| 25 |
public class Voice { |
| 26 |
public final String name; |
| 27 |
public final String identifier; |
| 28 |
public final int gender; |
| 29 |
public final int age; |
| 30 |
public final Locale locale; |
| 31 |
|
| 32 |
public Voice(String name, String identifier, int gender, int age, Locale locale) { |
| 33 |
this.name = name; |
| 34 |
this.identifier = identifier; |
| 35 |
this.gender = gender; |
| 36 |
this.age = age; |
| 37 |
this.locale = locale; |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
public int match(Locale query) { |
| 53 |
if (!locale.getISO3Language().equals(query.getISO3Language())) { |
| 54 |
return TextToSpeech.LANG_NOT_SUPPORTED; |
| 55 |
} |
| 56 |
try { |
| 57 |
if (!locale.getISO3Country().equals(query.getISO3Country())) { |
| 58 |
return TextToSpeech.LANG_AVAILABLE; |
| 59 |
} |
| 60 |
} catch (MissingResourceException e) { |
| 61 |
return TextToSpeech.LANG_AVAILABLE; |
| 62 |
} |
| 63 |
if (!locale.getVariant().equals(query.getVariant())) { |
| 64 |
return TextToSpeech.LANG_COUNTRY_AVAILABLE; |
| 65 |
} |
| 66 |
return TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE; |
| 67 |
} |
| 68 |
|
| 69 |
@Override |
| 70 |
public String toString() { |
| 71 |
String ret = locale.getISO3Language(); |
| 72 |
if (locale.getISO3Country() != null && !locale.getISO3Country().isEmpty()) { |
| 73 |
ret += '-'; |
| 74 |
ret += locale.getISO3Country(); |
| 75 |
} |
| 76 |
if (locale.getVariant() != null && !locale.getVariant().isEmpty()) { |
| 77 |
ret += '-'; |
| 78 |
ret += locale.getVariant(); |
| 79 |
} |
| 80 |
return ret; |
| 81 |
} |
| 82 |
} |