挪用Android系统语音TextToSpeech实例工具

详细代码写法如下:

TextToSpeech mTextToSpeech = new TextToSpeech(this, new TextToSpeech.OnInitListener() {

    @Override

 public void onInit(int status) {

if (status==TextToSpeech.SUCCESS) {

   //设置语言朗读

  int supported= mTextToSpeech.setLanguage(Locale.US);

 if ((supported!=TextToSpeech.LANG_AVAILABLE)&& (supported!=TextToSpeech.LANG_COUNTRY_AVAILABLE)) {

            Toast.makeText(this, "不支持当前语言!", Toast.LENGTH_SHORT).show();

                             }

                         }

                   }

          });

mTextToSpeech.speak("这里填入想要转成语音的文字", TextToSpeech.QUEUE_FLUSH, null);