如何判断一个特定的TTS引擎是否被选中(启用)?如何判断、引擎、TTS

2023-09-07 03:49:07 作者:四季的美好都不及你

此问题涉及在Android上的 2.2 仅

下面的屏幕截图显示了安装3个不同的文本到语音引擎:

在微微的TTS(Android的默认的升级Froyo 2.2) IVONA文本到语音HQ SVOX经典TTS

在这个截图中,你可以看到,并非所有的3选中(启用)。相反,IVONA被选中,只留下微微(暗示,因为它是在硬codeD)和SVOX(检查)。

我希望能够以编程方式从我的应用程序查询特定的TTS引擎(如IVONA)是否 检查 (假设我知道,在编码过程中的时间他们的包名,)。

易捷听打练习提速助手下载 易捷听打练习提速软件下载 v1.3 官方版

在Android的 2.2 我只有 getDefaultEngine()不能在这种情况真正帮助那里的微微被选定为默认值, SVOX 的检查(换句话说,我怎么知道的 SVOX 的检查,如果的微微的是默认?)

我如何做到这在Android中的 2.2

这是在所有可能的?

PS 的Andr​​oid 4.x版(API> = 14)推出 getEngines()这可能会导致您认为这个问题是解决了ICS +,但仔细观察发现是:

getEngines()只列出的安装,不是检查(启用)封装。 的 EngineInfo 附带列出的每个包中只提供名称,标签,图标,优先级,无论是系统映像的一部分。换句话说,同样的限制在Android 2.2的。 解决方案

见的的Andr​​oid TextToSpeech API指南

getEngines()会给所有已安装的引擎的列表,与每个一些信息。

getDefaultEngine()会给任何引擎用户选择作为默认的包名。

比较每个引擎的包名(或清单你必须提前)和默认引擎的包名,你就可以看到它被选中。

请注意,前者的功能只能从API级别14,但第二个是可从API级别8。

This question refers on Android 2.2 only:

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

PIco TTS (Android's default as of Froyo 2.2) IVONA Text-to-Speech HQ 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).

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:

getEngines() only lists installed, not checked (enabled) packages. 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.

解决方案

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.