Browse Source

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.
master
Reece H. Dunn 10 years ago
parent
commit
cfb2f9d3cb
1 changed files with 7 additions and 1 deletions
  1. 7
    1
      android/src/com/reecedunn/espeak/TtsService.java

+ 7
- 1
android/src/com/reecedunn/espeak/TtsService.java View File

@@ -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

Loading…
Cancel
Save