| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <template>
- <view class="">
- </view>
- </template>
- <script>
- var plugin = requirePlugin("WechatSI")
- let manager = plugin.getRecordRecognitionManager()
- export default {
- data() {
- return {
-
- };
- },
- created() {
- this.innerAudioContext = wx.createInnerAudioContext();
- this.innerAudioContext.onError(function(res) {
- uni.showToast({
- title: '语音播放初始化失败',
- })
- })
- },
- methods: {
- //阅读文字
- read(content) {
- var that = this;
- plugin.textToSpeech({
- lang: "zh_CN",
- tts: true,
- content,
- success: function(res) {
- that.auidoSrc=res.filename
- that.doRead();
- },
- fail: function(res) {
- wx.showToast({
- title: '语音转换失败',
- })
- }
- })
- },
- doRead() {
- this.innerAudioContext.src = this.auidoSrc //设置音频地址
- this.innerAudioContext.play(); //播放音频
- },
- }
- };
- </script>
- <style lang="scss" scoped>
- </style>
|