1、在微信公众平台登录小程序,添加插件微信同声翻译
搜索微信同传,点击添加进行开发。
[En]
Search for Wechat simultaneous interpretation and click add to develop.
代码
index.html
<view>
<button class="showCharacter" bindtap="wordYun">跟我读button>
view>
index.js
const app = getApp()
const plugin = requirePlugin('WechatSI');
Page({
data: {
content: '你好啊',
},
wordYun:function (e) {
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;
}
this.innerAudioContext.src = this.data.src
this.innerAudioContext.play();
},
)}
Original: https://blog.csdn.net/zi114323/article/details/111867433
Author: Rux子兮
Title: 小程序实现文字转语音
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/525145/
转载文章受原作者版权保护。转载请注明原作者出处!