diff --git a/android/eSpeakTests/src/com/reecedunn/espeak/test/SpeechSynthesisTest.java b/android/eSpeakTests/src/com/reecedunn/espeak/test/SpeechSynthesisTest.java index d687bd8b..d30f209f 100644 --- a/android/eSpeakTests/src/com/reecedunn/espeak/test/SpeechSynthesisTest.java +++ b/android/eSpeakTests/src/com/reecedunn/espeak/test/SpeechSynthesisTest.java @@ -23,7 +23,7 @@ import java.util.Locale; import java.util.Set; import com.reecedunn.espeak.SpeechSynthesis; -import com.reecedunn.espeak.SpeechSynthesis.Voice; +import com.reecedunn.espeak.Voice; import android.content.Intent; import android.content.pm.ActivityInfo; diff --git a/android/src/com/reecedunn/espeak/CheckVoiceData.java b/android/src/com/reecedunn/espeak/CheckVoiceData.java index b650b43a..f03f5a1d 100755 --- a/android/src/com/reecedunn/espeak/CheckVoiceData.java +++ b/android/src/com/reecedunn/espeak/CheckVoiceData.java @@ -32,7 +32,6 @@ import android.speech.tts.TextToSpeech.Engine; import android.util.Log; import com.reecedunn.espeak.SpeechSynthesis.SynthReadyCallback; -import com.reecedunn.espeak.SpeechSynthesis.Voice; import java.io.ByteArrayOutputStream; import java.io.File; diff --git a/android/src/com/reecedunn/espeak/SpeechSynthesis.java b/android/src/com/reecedunn/espeak/SpeechSynthesis.java index 015aedcd..965f45b1 100644 --- a/android/src/com/reecedunn/espeak/SpeechSynthesis.java +++ b/android/src/com/reecedunn/espeak/SpeechSynthesis.java @@ -27,7 +27,6 @@ package com.reecedunn.espeak; import android.content.Context; import android.content.res.Configuration; import android.content.res.Resources; -import android.speech.tts.TextToSpeech; import android.util.DisplayMetrics; import android.util.Log; @@ -345,51 +344,6 @@ public class SpeechSynthesis { void onSynthDataComplete(); } - public class Voice { - public final String name; - public final String identifier; - public final int gender; - public final int age; - public final Locale locale; - - public Voice(String name, String identifier, int gender, int age, Locale locale) { - this.name = name; - this.identifier = identifier; - this.gender = gender; - this.age = age; - this.locale = locale; - } - - /** - * Attempts a partial match against a query locale. - * - * @param query The locale to match. - * @return A text-to-speech availability code. One of: - * - */ - public int match(Locale query) { - if (!locale.getISO3Language().equals(query.getISO3Language())) { - return TextToSpeech.LANG_NOT_SUPPORTED; - } else if (!locale.getISO3Country().equals(query.getISO3Country())) { - return TextToSpeech.LANG_AVAILABLE; - } else if (!locale.getVariant().equals(query.getVariant())) { - return TextToSpeech.LANG_COUNTRY_AVAILABLE; - } else { - return TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE; - } - } - - @Override - public String toString() { - return locale.toString().replace('_', '-'); - } - } - private static String getIanaLocaleCode(String code, final Map javaToIana) { final String iana = javaToIana.get(code); if (iana != null) { diff --git a/android/src/com/reecedunn/espeak/TtsService.java b/android/src/com/reecedunn/espeak/TtsService.java index 808e14e7..710e3d21 100644 --- a/android/src/com/reecedunn/espeak/TtsService.java +++ b/android/src/com/reecedunn/espeak/TtsService.java @@ -40,7 +40,6 @@ import android.speech.tts.TextToSpeechService; import android.util.Log; import com.reecedunn.espeak.SpeechSynthesis.SynthReadyCallback; -import com.reecedunn.espeak.SpeechSynthesis.Voice; import java.util.List; import java.util.Locale; diff --git a/android/src/com/reecedunn/espeak/Voice.java b/android/src/com/reecedunn/espeak/Voice.java new file mode 100644 index 00000000..19907436 --- /dev/null +++ b/android/src/com/reecedunn/espeak/Voice.java @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2012-2013 Reece H. Dunn + * Copyright (C) 2011 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.reecedunn.espeak; + +import java.util.Locale; + +import android.speech.tts.TextToSpeech; + +public class Voice { + public final String name; + public final String identifier; + public final int gender; + public final int age; + public final Locale locale; + + public Voice(String name, String identifier, int gender, int age, Locale locale) { + this.name = name; + this.identifier = identifier; + this.gender = gender; + this.age = age; + this.locale = locale; + } + + /** + * Attempts a partial match against a query locale. + * + * @param query The locale to match. + * @return A text-to-speech availability code. One of: + * + */ + public int match(Locale query) { + if (!locale.getISO3Language().equals(query.getISO3Language())) { + return TextToSpeech.LANG_NOT_SUPPORTED; + } else if (!locale.getISO3Country().equals(query.getISO3Country())) { + return TextToSpeech.LANG_AVAILABLE; + } else if (!locale.getVariant().equals(query.getVariant())) { + return TextToSpeech.LANG_COUNTRY_AVAILABLE; + } else { + return TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE; + } + } + + @Override + public String toString() { + return locale.toString().replace('_', '-'); + } +} \ No newline at end of file