Search code examples
androidandroid-5.0-lollipoptext-to-speechflite

My TTS is not working in Android Lollipop (21)


I have created a TTS engine based on Flite for Android which works well on all versions below 21.

But when I run it in an Android Lollipop emulator, in the Text-to-Speech Settings screen, the option for reading a sample text is disabled and when I press the Settings button next to my TTS, the Settings crashes! However, the TTS works fine when used from other apps.


Solution

  • After hours of struggling, I finally found that using underscore (_) in locale names (like fas-IRN-male_odj) which was used in voice file names, confuses Android and it cannot parse language, country and variant parts out of it.

    It seems Android 21 treats _ and - both as separators in locale names and since it expects at most 3 parts for a locale definition (language, country and variant) falls in trouble with something that has 4 parts.