9

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.
Community
  • 1
  • 1
an00b
  • 11,338
  • 13
  • 64
  • 101

1 Answers1

0

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.

hcarver
  • 7,126
  • 4
  • 41
  • 67
  • Sorry, I forgot to emphasize that I am looking for an Android **2.2** compatible solution. As you correctly noted, `getEngines()` is only availabe from API 14. `getDefaultEngine()` can't really help in a situation where *Pico* is selected as default and *SVOX* is checked. How do I know that *SVOX* is checked if *Pico* is the default? – an00b Aug 22 '12 at 14:48
  • 2
    In future, please say in a comment that you're editing a question - my answer just got downvoted and I'd guess it's because the question now says all the stuff in the answer. I can't see anything in the android docs that'd tell you about checked engines at API 8,so I think it might be impossible. – hcarver Aug 23 '12 at 06:20
  • Sorry about that. IMHO, you should delete this answer because neither `getEngines()` nor `getDefaultEngine()` are capable of helping tell whether a specific TTS engine is **checked**. It is better that this question remains unanswered, so that people will know that **it isn't possible** to tell whether a specific TTS engine is **checked**. +1 for your comment. – an00b Aug 23 '12 at 15:02
  • 1
    BTW, even in ICS+ (4.x) `getEngines()` only returns the list of **installed** TTS engines. "Installed" is not the same as **enabled** (checked). – an00b Aug 23 '12 at 15:05
  • 1
    But... in ICS+ (4.x) installed always means enabled. The only problem remaining is for 2.2 but for lack of other answers I am accepting yours. – an00b Sep 07 '12 at 14:23