Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 提供默认语言的TTS实现_Android_Text To Speech - Fatal编程技术网

Android 提供默认语言的TTS实现

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

我正在开发一些Android应用程序,我想提供一种可能性(假设手机支持)来“阅读”文本——在西班牙语应用程序中,它将分别是西班牙语语音、法语和法语

我能不能从两件事中选一件:

  • 检查此特定语言是否可用
  • 如果它不可用-下载它或给用户下载它的可能性
  • 它有什么模式吗?

    1)您可以使用内置方法轻松检查请求的语言是否可用

    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-我没有看到负责下载哪种语言的参数-我是否遗漏了一些内容?这将打开一个包含所有可安装语言的对话框。不要认为你可以指定一种特定的语言