我正在使用 TTS 功能在 Android 中设计一个应用程序。请建议我在 API 8 中找到 TTS 引擎存在的好方法
问问题
46 次
1 回答
0
您使用意图检查文本到语音
Intent intent = new Intent();
intent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
ArrayList<String> languages = new ArrayList<String>();
languages.add("eng-USA"); // Whatever language you want
intent.putStringArrayListExtra(TextToSpeech.Engine.EXTRA_CHECK_VOICE_DATA_FOR,
languages);
startActivityForResult(intent, 1);
然后onActivityResult
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent)
{
super.onActivityResult(requestCode, resultCode, intent);
switch (requestCode)
{
case 1:
if (resultCode != TextToSpeech.Engine.CHECK_VOICE_DATA_PASS)
{
// Tts failed go to google play store to download
}
break;
}
}
于 2013-05-25T18:24:37.433 回答