c***@163.com
c***@163.com
  • 发布:2017-02-25 14:08
  • 更新:2019-11-14 12:23
  • 阅读:2314

SynthesizerPlayer.createSynthesizer 如何设置英语发音人

分类:HBuilder

SynthesizerPlayer.createSynthesizer 如何设置英语发音人????

2017-02-25 14:08 负责人:无 分享
已邀请:
赵梦欢

赵梦欢 - 专注前端,乐于分享!

<!doctype html>  
<html>  

    <head>  
        <meta charset="UTF-8">  
        <title></title>  
        <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />  
        <link href="css/mui.min.css" rel="stylesheet" />  
        <style type="text/css">  
            .text{  
                margin: 10px;  
                background-color: #eee;  
                padding: 5px;  
            }  
        </style>  
    </head>  

    <body>  
        <header class="mui-bar mui-bar-nav">  
            <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>  
            <h1 class="mui-title">语音合成</h1>  
        </header>  
        <div class="mui-content mui-content-padded">  
            <div class="text">Perhaps every program has a dream of changing the world, perhaps to the end we can only change our own. We are good for the division, we are eager to become Daniel is looking up, we love to share, because the program ape this enthusiasm, the overall social technology more and more mature, open source to change the world, but also change this procedure ape. I am not a big god, I just want to quietly do something meaningful.</div>  
            <button id="btn" type="button" class="mui-btn mui-btn-block">开始合成</button>  
        </div>  
        <script src="js/mui.min.js"></script>  
        <script type="text/javascript">  
            mui.init();  

            mui.plusReady(function () {  
                var main = plus.android.runtimeMainActivity();  
                var SpeechUtility = plus.android.importClass('com.iflytek.cloud.SpeechUtility');  
                var SpeechConstant = plus.android.importClass('com.iflytek.cloud.SpeechConstant');  
                SpeechUtility.createUtility(main,"appid=H52A639CD");  

                var SynthesizerPlayer = plus.android.importClass('com.iflytek.cloud.SpeechSynthesizer');  
                var mTts = SynthesizerPlayer.createSynthesizer(main, null);   
                mTts.setParameter(SpeechConstant.VOICE_NAME, "catherine");//设置发音人  
                mTts.setParameter(SpeechConstant.SPEED, "50");//设置语速    
                mTts.setParameter(SpeechConstant.VOLUME, "80");//设置音量,范围0~100    
                mTts.setParameter(SpeechConstant.ENGINE_TYPE, SpeechConstant.TYPE_CLOUD); //设置云端    

                document.querySelector('#btn').addEventListener('tap',function () {  
                    var text = document.querySelector(".text").innerHTML;  
                    mTts.startSpeaking(text,null);  
                })  
            })  
        </script>  
    </body>  
</html>

详细参考科大讯飞文档:语音合成

  • 下一页丶翻

    大神,mTts.startSpeaking(text,null) null处是不是可用监听是否阅读完?回调的参数是啥

    2017-12-12 17:19

  • 赵梦欢

    回复 下一页丶翻: 写成插件可以很方便的实现回调

    2017-12-13 09:19

c***@163.com

c***@163.com (作者)

多谢,非常好!!!
驾培

5***@qq.com

5***@qq.com - 70后IT老头

播报的语音跟文字完全不对应啊?楼主

该问题目前已经被锁定, 无法添加新回复