您当前的位置: 首页 >  android

ZhangJiQun&MXP

暂无认证

  • 0浏览

    0关注

    1187博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

android实现语音播报textToSpeech

ZhangJiQun&MXP 发布时间:2020-09-16 17:44:58 ,浏览量:0

  private void startAuto(String data) {
        // 设置音调,值越大声音越尖(女生),值越小则变成男声,1.0是常规
        textToSpeech.setPitch(1.0f);
        // 设置语速
        textToSpeech.setSpeechRate(1.0f);
        textToSpeech.speak(data,//输入中文,若不支持的设备则不会读出来
                TextToSpeech.QUEUE_FLUSH, null);

    }

    private void initTTS() {
        //实例化自带语音对象
        textToSpeech = new TextToSpeech(this, new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(int status) {
                if (status == textToSpeech.SUCCESS) {

                    textToSpeech.setPitch(1.0f);//方法用来控制音调
                    textToSpeech.setSpeechRate(1.0f);//用来控制语速

                    //判断是否支持下面两种语言
                    int result1 = textToSpeech.setLanguage(Locale.US);
                    int result2 = textToSpeech.setLanguage(Locale.
                            SIMPLIFIED_CHINESE);
                    boolean a = (result1
关注
打赏
1665659684
查看更多评论
立即登录/注册

微信扫码登录

0.0404s