const app = getApp();
const plugin = requirePlugin('WechatSI');
Page({
data: {
content: '新京报快讯 据国家卫健委网站消息,2月26日0—24时,31个省(自治区、直辖市)和新疆生产建设兵团报告新增确诊病例10例,均为境外输入病例(广东5例,陕西2例,天津1例,上海1例,四川1例);无新增死亡病例;新增疑似病例1例,为境外输入病例(在上海)。当日新增治愈出院病例24例,解除医学观察的密切接触者3689人,重症病例与前一日持平。',
src:'https://ae.weixin.qq.com/cgi-bin/mmasrai-bin/getmedia?filename=1614394867_ebfff9c97904f891e5032d94e51198b7&filekey=597107874&source=miniapp_plugin',
},
onReady(e) {
this.innerAudioContext = wx.createInnerAudioContext();
this.innerAudioContext.onError(function (res) {
console.log(res);
wx.showToast({
title: '语音播放失败',
icon: 'none',
})
})
},
conInput: function (e) {
this.setData({
content: e.detail.value,
})
},
wordYun:function (e) {
console.log("====");
var that = this;
var content = this.data.content;
plugin.textToSpeech({
lang: "zh_CN",
tts: true,
content: content,
success: function (res) {
console.log(res);
console.log("succ tts", res.filename);
that.setData({
src: res.filename
})
that.yuyinPlay();
},
fail: function (res) {
console.log("fail tts", res)
}
})
},
yuyinPlay: function (e) {
if (this.data.src == '') {
console.log(暂无语音);
return;
}
console.log("----"+this.data.src);
this.innerAudioContext.src = this.data.src
console.log("----"+this.innerAudioContext.src);
this.innerAudioContext.play();
},
end: function (e) {
this.innerAudioContext.pause();
},
})
有解决的么