3
我开发了一个基于Android 2.3的TTS的应用程序。 我注意到,在最新版本的Android(4.2.2)中,例如,没有默认安装的默认TTS语言,您必须手动下载它们: 设置 - >语言和输入 - >文本到语音输出 - >谷歌文本转语音 - >安装语音数据自动下载安卓TTS引擎
有没有办法自动安装一种语言?
我开发了一个基于Android 2.3的TTS的应用程序。 我注意到,在最新版本的Android(4.2.2)中,例如,没有默认安装的默认TTS语言,您必须手动下载它们: 设置 - >语言和输入 - >文本到语音输出 - >谷歌文本转语音 - >安装语音数据自动下载安卓TTS引擎
有没有办法自动安装一种语言?
有没有办法自动安装一种语言?
是的,但不会自动(未经用户许可)作为docs提到的发生:
由于数据的安装可以被中断或用户下降,应用程序不应该期望从该意图返回时成功安装...
无论如何,您可以触发安装方法如this:
/**
* Ask the current default engine to launch the matching INSTALL_TTS_DATA activity
* so the required TTS files are properly installed.
*/
private void installVoiceData() {
Intent intent = new Intent(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setPackage("com.google.android.tts"/*replace with the package name of the target TTS engine*/);
try {
Log.v(TAG, "Installing voice data: " + intent.toUri(0));
startActivity(intent);
} catch (ActivityNotFoundException ex) {
Log.e(TAG, "Failed to install TTS data, no acitivty found for " + intent + ")");
}
}