Home » Android » android – How to tell whether a specific TTS engine is checked (enabled)?

android – How to tell whether a specific TTS engine is checked (enabled)?

Posted by: admin June 15, 2020 Leave a comment

Questions:

This question refers on Android 2.2 only:

The following screenshot shows 3 different text-to-speech engines installed:

  1. PIco TTS (Android’s default as of Froyo 2.2)
  2. IVONA Text-to-Speech HQ
  3. SVOX Classic TTS

In this screenshot, you could see that not all 3 are checked (enabled). Instead, IVONA is unchecked, leaving only Pico (implied, as it’s hard-coded in) and SVOX (checked).

enter image description here

I would like to be able to programmatically query from my application whether a specific TTS engine (e.g. IVONA) is checked (assuming I know at coding time their package names, of course).

In Android 2.2 all I have is getDefaultEngine() which can’t really help in a situation where Pico is selected as default and SVOX is checked (in other words, how do I know that SVOX is checked if Pico is the default?)

How do I accomplish that in Android 2.2?

Is this at all possible?

P.S. Android 4.x (API >= 14) introduced getEngines() which may lead you to believe that this problem is solved for ICS+ but closer examination reveals that:

  1. getEngines() only lists installed, not checked (enabled) packages.
  2. The EngineInfo that comes with each listed package only provides name, label, icon, priority and whether it is part of the system image. In other words, same limitation as in Android 2.2.
How to&Answers:

See the Android TextToSpeech API guide

getEngines() will give a list of all the engines that are installed, with some info about each.

getDefaultEngine() will give the package name of whichever engine the user has chosen as default.

Comparing the package name of each engine (or a list you have in advance) with the default engine’s package name, you’ll be able to see which is selected.

Note that the former function is only available from API level 14, though the second is available from API level 8.