android - 是否应该在较新的 android 平台上检查文本到语音引擎的存在?

标签 android

在 Android Froyo-api8 到 Gingerbread api-10 中,Text-To-Speech 并不总是安装在系统上。前段时间听说从某个API开始,TTS将成为Android不可或缺的一部分。

我想阻止在新平台上运行的代码中进行TTS 可用性检查。有没有人有这方面的经验?

是否有任何关于文本转语音引擎的官方文档表明它将在某些平台上可用?

为了详细说明,我使用这段代码来检查 TTS 是否存在。

        final Intent checkIntent = new Intent();
        checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
        sourceActivity.startActivityForResult(checkIntent, TTS_CHECK_REQ);

在 onActivityResult 中,我将 resultcode 与 CHECK_VOICE_DATA_PASS 进行匹配,以判断成功与否。

最佳答案

来自Android Developer's Blog :

Although all Android-powered devices that support the TTS functionality ship with the engine, some devices have limited storage and may lack the language-specific resource files. If a user wants to install those resources, the TTS API enables an application to query the platform for the availability of language files and can initiate their download and installation. So upon creating your activity, a good first step is to check for the presence of the TTS resources with the corresponding intent: (your example intent follows)

我从中了解到,引擎 是平台的核心部分。但是,语音数据 不是,而这正是您的 Intent 实际要检查的内容。不过,我不会禁用此检查,因为并非所有设备都保证在发货时安装了数据。

当然,最新的 Galaxy 或 Nexus 会,但更便宜的手机呢? 真正的便宜的怎么样?他们可能正在运行 ICS 或 JB,但制造商可能已经跳过,或者只是想节省磁盘空间。自定义 ROM 怎么样?有些人以剥离 Android 的“膨胀”而自豪。我几乎可以保证至少有一个会删除语音数据。

关于android - 是否应该在较新的 android 平台上检查文本到语音引擎的存在?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14389988/

相关文章:

android - 如何检测语音

android - 滑动菜单切换选项

android - android PagerAdapter的instantiateItem是什么时候调用的?

java - 带有 GBoard 输入的 EditText 首字母大写

android设置android可绘制颜色

android - 地理围栏形状,API v2 android

android - 如何在 Android 上读取/写入外部 USB 存储?

android - Android 4.1.2 Phonegap (Cordova) 中的自定义波斯语和阿拉伯语字体不起作用

java - 如何从 xml 文件项更改 ListView 中 TextView 的字体颜色?安卓

android - "android-support-v7-appcompat"的ActionBarActivity和ListActivity在同一个activity