首页 > 移动平台 > 详细

编写使用Android 系统自带的文字转语音代码

时间:2020-08-17 22:19:09      阅读:72      评论:0      收藏:0      [点我收藏+]
调用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);

编写使用Android 系统自带的文字转语音代码

原文:https://blog.51cto.com/1206995290qq/2521094

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!