if(parseInt(ver) >= 8){ //判断安卓版本,大于8以上的走百度语音合成
var timestamp = Date.parse(new Date());
if(!plus.storage.getItem("oneTime")){
getBaiDuToken(msg.content); //获取百度token
plus.storage.setItem("oneTime",JSON.stringify(timestamp));
}else{
var oneTime = plus.storage.getItem("oneTime");
if((parseInt(timestamp)-parseInt(oneTime)) > 24*60*60){ //因为token24小时后过期,重新获取一次
console.log("大于24小时");
plus.storage.setItem("oneTime",JSON.stringify(timestamp)); //大于24小时就更新,再次获取token
getBaiDuToken(msg.content); //获取百度token
}else{
//小于24小时无需重新获取百度token
console.log("小于24小时");
baiduAubio(msg.content);
}
}
}else{//讯飞语音合成
var main = plus.android.runtimeMainActivity();
var SpeechUtility = plus.android.importClass('com.iflytek.cloud.SpeechUtility');
SpeechUtility.createUtility(main, "appid=你的ID");
var SynthesizerPlayer = plus.android.importClass('com.iflytek.cloud.SpeechSynthesizer');
var play = SynthesizerPlayer.createSynthesizer(main, null);
play.startSpeaking(msg.content, null);
}
大神给出的解决方案 因为平台的原因 改用百度及讯飞混用的方案