Fix TextToSpeech,setLanguage on Android 5.0.

As of Android 5.0, TextToSpeech.setLanguage calls the new
TextToSpeechService.onGetDefaultVoiceNameFor(lang,country,variant)
and uses the specified voice name.

The default Android 5.0 implementation of onGetDefaultVoiceNameFor
does not work with eSpeak. This provides a working implementation.

This fixes the TextToSpeechTest.testLanguages tests on Android 5.0.
This commit is contained in:
Reece H. Dunn
2014-10-30 12:28:32 +00:00
parent 98208df155
commit cfb2f9d3cb
@@ -201,7 +201,13 @@ public class TtsService extends TextToSpeechService {
@Override
public String onGetDefaultVoiceNameFor(String language, String country, String variant) {
return super.onGetDefaultVoiceNameFor(language, country, variant);
final int result = onLoadLanguage(language, country, variant);
switch (result) {
case TextToSpeech.LANG_MISSING_DATA:
case TextToSpeech.LANG_NOT_SUPPORTED:
return null;
}
return mMatchingVoice.name;
}
@Override