(function (){
if(document.getElementById('mxsource')){
{
var spd=5;
//默认语速为5,数字越大语速越快,可自行修改
var per=4;
//语调或语声,默认为4,可修改为1到6
var input= document.getElementsByTagName('input');
if(input&&input.length>0)
{}
else{
if(document.getElementById('hastts')){}
else{
var vol=5;
var txt=document.body.innerText;
if(txt.length>0){
try{
txt=txt.replace(/\r\n/g,"")
txt=txt.replace(/\n/g,"");
}catch(e) {
}
var vcurrent = document.getElementsByTagName('body')[0];
var newNodeTop;
var n = 1600;
if(/.*[\u4e00-\u9fa5]+.*$/.test(txt))
{
n=500;
}
var num=0;
var hastts = document.createElement("div");
hastts.id="hastts";
vcurrent.appendChild(hastts);
for (var i = 0, l = txt.length; i < l/n; i++) {
var a = txt.slice(n*i, n*(i+1));
num++;
newNodeTop = document.createElement("audio");
newNodeTop.id="mutts3";
newNodeTop.setAttribute("controls","");
//newNodeTop.setAttribute("autoplay","autoplay");
a=encodeURIComponent(a) ;
newNodeTop.setAttribute("src","
http://tts.baidu.com/text2audio?idx=1&cuid=baidu_speech_demo&cod=5&lan=zh&ctp=1&pdt=1&spd="+spd+"&vol="+vol+"&pit=3&per="+per+"&tex="+a); vcurrent.parentNode.insertBefore(newNodeTop, vcurrent);
}
if(num>1){
try{
window.mx_browser_obj.showtip("已分为"+num+"段语音朗读");
}catch(e) {
}
}
}
}
}//hastts
}//input
}
})();