initReadPlugin: function () {//初始化,播放插件innerAudioContext.onWaiting(() => {debugger});innerAudioContext.onCanplay(() => {debugger});innerAudioContext.onPlay(() => {debugger});innerAudioContext.onPause(() => {});innerAudioContext.onEnded(() => {// debugger// console.log("播放自然结束");});innerAudioContext.onError((res) => {})},//filename 为 语音合成插件了返回的地址,经测试是正常的 innerAudioContext.autoplay = true innerAudioContext.src = res.filename; |
预期:
当下面两行代码执行后,应该有语音播放出来,
innerAudioContext.autoplay = true innerAudioContext.src = res.filename;bug:
苹果机正常播放,安卓机要很长时间才会播放,或者是根本没有声音(安卓机时,很慢才会到play等的监听事件,有时候到了stop事件,也没有声音)

这个问题现在还有,有时可以很快,但大部分时候要很久才返回音频文件,平均三四十秒,不知道是不是文字太多了,动态生成的,差不多50个文字左右
兄弟 这个问题解决了么 我也遇到了
机型:拿大概5部安卓机进行测试,oppo、华为、coolpad等,都有这个问题,ios没有。
代码片段:
https://developers.weixin.qq.com/s/YV6bSYm37V3r
提供一下出现问题的机型和微信版本,以及能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。
const app = getApp()const innerAudioContext = wx.createInnerAudioContext()Page({data: {},onLoad:function() {this.initReadPlugin();},testread:function(){debugger// innerAudioContext.stop();innerAudioContext.autoplay =true;innerAudioContext.obeyMuteSwitch =false;innerAudioContext.src ="https://ae.weixin.qq.com/cgi-bin/mmasrai-bin/getmedia?filename=6055837418496065539_6055837418496065539&filekey=127878962&source=miniapp_plugin";},initReadPlugin:function() {//初始化,播放插件innerAudioContext.onWaiting(() => {debugger});innerAudioContext.onCanplay(() => {debugger});innerAudioContext.onPlay(() => {debugger});innerAudioContext.onPause(() => {debugger});innerAudioContext.onEnded(() => {debugger});innerAudioContext.onError((res) => {debugger})},})不知道代码片段的使用方式对不对,所以,把关键代码拿出来了。
上面的url地址,是文本合成语音的插件返回的值,可以进行下载播放,那ios机测试,没有问题,声音可以直接播放。
1、合成插件正确返回结果
2、过了很久很久,才会进到下面debug
3、进入后,有时候可以正确朗读,有时候不能
这个网址是文本转语音的插件返回的结果-:res.filename。
我把这个网址的音频下载下来,在windows系统上,是可以正常播放的。
这个网址在ios系统上也是可以正常播放的,但是在安卓就不可以用了。执行autoplay这句话后,会很久才会触发onplay事件,但是,音频却只读了一半就会报错(onerror)。也就是,在安卓机上,插件返回的地址音频文件,偶尔发音、偶尔不发音,这又是怎么回事呢。
"plugins": {"WechatSI": {"version":"0.2.0","provider":"wx069ba97219f66d99"}}plugin.textToSpeech({lang:"zh_CN",tts:true,content: text,success:function(res) {debuggerconsole.log("success");innerAudioContext.autoplay =true;// innerAudioContext.obeyMuteSwitch = false;innerAudioContext.src = res.filename;这个问题解决没,兄弟