Android 提供默认语言的TTS实现
我正在开发一些Android应用程序,我想提供一种可能性(假设手机支持)来“阅读”文本——在西班牙语应用程序中,它将分别是西班牙语语音、法语和法语 我能不能从两件事中选一件:Android 提供默认语言的TTS实现,android,text-to-speech,Android,Text To Speech,我正在开发一些Android应用程序,我想提供一种可能性(假设手机支持)来“阅读”文本——在西班牙语应用程序中,它将分别是西班牙语语音、法语和法语 我能不能从两件事中选一件: 检查此特定语言是否可用 如果它不可用-下载它或给用户下载它的可能性 它有什么模式吗?1)您可以使用内置方法轻松检查请求的语言是否可用 TextToSpeech tts = new TextToSpeech(this, this); //Use this to get the default locale tts.isLa
TextToSpeech tts = new TextToSpeech(this, this);
//Use this to get the default locale
tts.isLanguageAvailable(Locale.getDefault());
//Otherwise hardcode the language you want to check for
tts.isLanguageAvailable(Locale.FRENCH());
2) 您还可以通过激发下载意图,为用户提供下载的可能性
Intent installIntent = new Intent();
installIntent
.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
startActivity(installIntent);
看起来几乎完美-只有一个问题(在接受之前)-关于示例2-我没有看到负责下载哪种语言的参数-我是否遗漏了一些内容?这将打开一个包含所有可安装语言的对话框。不要认为你可以指定一种特定的语言