微信小程序实现文字转语音播放
最编程
2024-04-27 20:16:11
...
1:登录微信服务平台
https://fuwu.weixin.qq.com/search?tab=3&type=&serviceType=3&page=1#search-page
2:找到了微信同声传译,登录后选择给哪个小程序添加,添加成功后去小程序的微信公众平台看已经添加成功了,而且是已通过状态。
https://blog.****.net/Yang_XiaoYang/article/details/119776605
3:、在微信公众平台登录小程序,添加获取APPID(不可以用测试号,否则功能实现不了),
将获取到的APPID填写至微信小程序开发工具中
4:app.json中进行注册微信同声翻译
"plugins": { "WechatSI": { "version": "0.3.4", "provider": "wx069ba97219f66d99" } }
5:js中进行引用
//获取应用实例 const app = getApp() //引入插件:微信同声传译 const plugin = requirePlugin('WechatSI')
data 中写内容
// 语音识别的内容 content: '我是王越666',//内容
生命周期函数中
//创建内部 audio 上下文 InnerAudioContext 对象。 this.innerAudioContext = wx.createInnerAudioContext();
函数外定义方法
// 文字转语音 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(); //播放音频 },
html中:
<view> <button class="showCharacter" bindtap="wordYun">跟我读</button> </view>
效果图:这里可以换成图标
原文地址:https://www.cnblogs.com/xiaoyantongxue/p/16227377.html
推荐阅读
-
微信小程序嵌套webview页面实现导航,可跳转至高德百度等小程序
-
微信小程序的实现 底部导航栏未读消息出现小红点
-
微信 "扫一扫 "物联网,全面揭秘 "扫一扫 "背后的扫盲技术!-1.1 扫一扫感知物体是做什么的? 1.1 微信扫一扫是做什么的? 扫一扫识物是指以图片或视频(商品图片:鞋/包/美妆/服饰/家电/玩具/图书/食品/珠宝/家具/其他商品)为输入媒介,挖掘微信内容生态中的有价值信息(电商+百科+资讯,如图1所示),并展示给用户。这里的电商基本涵盖了微信小程序覆盖上亿SKU的全量优质电商,可以支持用户货比N家并直接下单购买,百科和资讯则聚合了微信内的头部自媒体如搜狗、搜搜、百度等,向用户展示和分享拍摄商品相关的内容资讯。 图 1 扫一扫识别功能示意图 欢迎大家更新iOS新版微信→扫一扫→识货,亲自体验,也欢迎大家通过识货界面的反馈按钮向我们提交反馈意见。 扫一扫识物实景图展示 1.2 扫一扫识物有哪些使用场景? 扫一扫识物的目的是为用户访问微信内部生态内容开辟一个新窗口,以用户扫图片为输入形式,为用户提供微信生态内容中的百科、资讯、电商等作为展示页面。除了用户熟悉的扫一扫操作外,我们还将进一步拓展长按操作,让用户更方便地进行扫一扫操作。"扫一扫知事 "的落地场景主要涵盖三大部分: a. 科普知识: a.科普知识。用户通过扫一扫,可以在微信生态圈中获取该对象的百科、资讯等常识或趣闻,帮助用户更好地了解该对象; b.购物场景。同样的搜索功能支持用户看到喜欢的商品立即检索到微信小程序电商中的同款商品,支持用户即扫即购; c.广告场景。扫一扫识别物体可以辅助公众号文章、视频更好地理解其中蕴含的图片信息,从而更好地投放匹配广告,提高点击率。 1.3 Sweep Sense 为 Sweep 家族带来了哪些新技术? 对于扫一扫来说,大家耳熟能详的应该就是扫一扫二维码、扫一扫小程序码、扫一扫条形码、扫一扫翻译了。无论是各种形式的编码还是文字字符,都可以看作是图片的一种特定编码形式,而物的识别则是对自然场景图片的识别,这对于扫一扫家族来说是一个质的飞跃,我们希望从物的识别入手,进一步拓展扫一扫对自然场景图片的理解能力,比如扫酒、扫车、扫植物、扫人脸等服务,如下图3所示。 图 3 Sweep 家族
-
微信公众号--小程序实现人脸核身(人脸识别)
-
微信小程序 语音转换
-
微信小程序语音识别服务打造全流程解析(https api开放,支持新界面mp3录音、旧界面silk录音)
-
微信小程序在录制示例时实现麦克风动画效果
-
微信小程序语音广播
-
微信小程序转发功能实现
-
微信小程序实现 "转发到朋友圈"、"分享到朋友圈