我正在使用TTS功能在Android中设计APP。请建议我在API 8中找到TTS引擎的好方法
答案 0 :(得分: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;
}
}