use of android.speech.tts.Voice in project robolectric by robolectric.
the class ShadowTextToSpeechTest method getCurrentVoice_voiceSet_returnsVoice.
@Test
@Config(minSdk = LOLLIPOP)
public void getCurrentVoice_voiceSet_returnsVoice() {
TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {
});
Voice voice = new Voice("test voice", Locale.getDefault(), Voice.QUALITY_VERY_HIGH, Voice.LATENCY_LOW, false, /* requiresNetworkConnection */
ImmutableSet.of());
textToSpeech.setVoice(voice);
assertThat(shadowOf(textToSpeech).getCurrentVoice()).isEqualTo(voice);
}
use of android.speech.tts.Voice in project robolectric by robolectric.
the class ShadowTextToSpeechTest method getVoices_returnsAvailableVoices.
@Test
@Config(minSdk = LOLLIPOP)
public void getVoices_returnsAvailableVoices() {
TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {
});
Voice voice = new Voice("test voice", Locale.getDefault(), Voice.QUALITY_VERY_HIGH, Voice.LATENCY_LOW, false, /* requiresNetworkConnection */
ImmutableSet.of());
ShadowTextToSpeech.addVoice(voice);
assertThat(shadowOf(textToSpeech).getVoices()).containsExactly(voice);
}
use of android.speech.tts.Voice in project Saiy-PS by brandall76.
the class SaiyTextToSpeech method getEngineDefaultSaiyVoice.
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private SaiyVoice getEngineDefaultSaiyVoice() {
final Voice voice = getDefaultVoice();
if (voice != null) {
final SaiyVoice saiyVoice = new SaiyVoice(voice);
saiyVoice.setEngine(getInitialisedEngine());
saiyVoice.setGender(saiyVoice.getName());
if (DEBUG) {
MyLog.i(CLS_NAME, "getEngineDefaultSaiyVoice: setting Gender: " + saiyVoice.getGender().name());
}
return saiyVoice;
} else {
if (DEBUG) {
MyLog.i(CLS_NAME, "getEngineDefaultSaiyVoice: voice null");
}
return null;
}
}
use of android.speech.tts.Voice in project Saiy-PS by brandall76.
the class SaiyTextToSpeech method getBoundSaiyVoice.
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public SaiyVoice getBoundSaiyVoice() {
final Voice voice = getVoice();
if (voice != null) {
final SaiyVoice saiyVoice = new SaiyVoice(voice);
saiyVoice.setEngine(getInitialisedEngine());
saiyVoice.setGender(saiyVoice.getName());
return saiyVoice;
} else {
return null;
}
}
use of android.speech.tts.Voice in project Saiy-PS by brandall76.
the class SaiyVoice method getSaiyVoices.
public static Set<SaiyVoice> getSaiyVoices(@NonNull final Set<Voice> voiceSet, @NonNull final String initialisedEngine) {
final Set<SaiyVoice> saiyVoiceSet = new HashSet<>(voiceSet.size());
if (initialisedEngine.matches(TTSDefaults.TTS_PKG_NAME_GOOGLE)) {
final TTSDefaults.Google[] googleList = TTSDefaults.Google.values();
SaiyVoice saiyVoice;
String voicePattern;
for (final Voice voice : voiceSet) {
saiyVoice = new SaiyVoice(voice);
saiyVoice.setEngine(initialisedEngine);
voicePattern = Pattern.quote(voice.getName());
for (final TTSDefaults.Google g : googleList) {
if (g.getVoiceName().matches(voicePattern)) {
saiyVoice.setGender(g.getGender());
break;
}
}
saiyVoiceSet.add(saiyVoice);
}
} else {
SaiyVoice saiyVoice;
for (final Voice voice : voiceSet) {
saiyVoice = new SaiyVoice(voice);
saiyVoice.setEngine(initialisedEngine);
saiyVoice.setGender(Gender.getGenderFromVoiceName(voice.getName()));
saiyVoiceSet.add(saiyVoice);
}
}
return saiyVoiceSet;
}