diff --git a/.hbuilderx/launch.json b/.hbuilderx/launch.json index f83558e..472ec0d 100644 --- a/.hbuilderx/launch.json +++ b/.hbuilderx/launch.json @@ -13,7 +13,7 @@ "type" : "uniCloud" }, { - "playground" : "standard", + "playground" : "custom", "type" : "uni-app:app-android" }, { diff --git a/api/api.js b/api/api.js index 29f717d..345116e 100644 --- a/api/api.js +++ b/api/api.js @@ -18,6 +18,31 @@ export function ttWss(data) { return requesta.post(`index/tts`, data); } + + + +// base64 转 二进制流(blob) +export function dataURLtoBlob(dataurl) { + // console.log(dataurl); + // let str = "data:audio/wav;base64," + dataurl.slice(2) + // console.log(str); + let mime = "audio/wav" + // var arr = str.split(","), + // mime = arr[0].match(/:(.*?);/), + // let bstr = atob(arr[1]) + let bstr = atob(dataurl) + let n = bstr.length + let u8arr = new Uint8Array(n); + while (n--) { + u8arr[n] = bstr.charCodeAt(n); + } + console.log(u8arr) + // return new Blob([u8arr], { + // type: mime, + // }); +} + + // -防抖 export function debounce(fn, wait) { let delay = wait || 500 diff --git a/components/qiqb-share/qiqb-share.vue b/components/qiqb-share/qiqb-share.vue index 853df22..d6c23f7 100644 --- a/components/qiqb-share/qiqb-share.vue +++ b/components/qiqb-share/qiqb-share.vue @@ -366,7 +366,7 @@ success: (res) => { uni.hideLoading() console.log(res) - this.$emit('down', res) + this.show = false // 保存到相册 自定义实现 uni.saveImageToPhotosAlbum({ diff --git a/components/qiqb-share/qiqb-share1.vue b/components/qiqb-share/qiqb-share1.vue new file mode 100644 index 0000000..0dc3ca9 --- /dev/null +++ b/components/qiqb-share/qiqb-share1.vue @@ -0,0 +1,444 @@ + + + + + + \ No newline at end of file diff --git a/pages/index/index.vue b/pages/index/index.vue index ed74e09..0ad71ce 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -182,7 +182,7 @@ - + @@ -194,7 +194,9 @@ iatWss, debounce, throttle, - ttWss + fileToBase64, + dataURLtoBlob, + ttWss, } from "@/api/api.js" import { HTTP_REQUEST_URL @@ -379,14 +381,14 @@ let arry1 = [] let a; let b; - if(data.length>2){ - a=data.length-2 - b=data.length-1 - }else{ - a=0 - b=1 - } - + if (data.length > 2) { + a = data.length - 2 + b = data.length - 1 + } else { + a = 0 + b = 1 + } + for (let i in data[a].content) { if (data[a].content.slice(i * 22, (i + 1) * 22)) { arry.push(data[a].content.slice(i * 22, (i + 1) * 22)) @@ -397,14 +399,14 @@ if (data[b].content.slice(i * 22, (i + 1) * 22)) { arry1.push(data[b].content.slice(i * 22, (i + 1) * 22)) } - - + + } // console.log(arry1.length,arry.length) - this.imageSize.height=(arry1.length*20)+(arry.length*20)+100+150 - - this.$refs.child.refresh(this.talkList,this.imageSize.height,(arry.length*20)+100); + this.imageSize.height = (arry1.length * 20) + (arry.length * 20) + 100 + 150 + + this.$refs.child.refresh(this.talkList, this.imageSize.height, (arry.length * 20) + 100); }, @@ -418,7 +420,7 @@ }, //分享 Share() { - + // this.isDraw = !this.isDraw; this.cavshare(this.talkList) this.$refs.child.init() @@ -628,6 +630,38 @@ } // #endif }, + // 调用讯飞语音识别 + voiceBegain() { + let _this = this; + let options = {}; + //#ifdef APP-PLUS || APP-PLUS-NVUE + options.engine = 'iFly'; + options.punctuation = false; // 是否需要标点符号 + options.timeout = 10 * 6000; //语音录入持续时长 + + plus.speech.startRecognize(options, function(s) { + _this.searchText = _this.searchText + s; + console.log(_this.searchText) //拿到语音识别的结果 + //下面是逻辑 + _this.searchValue = s; + _this.searchText = "" + + // 打印输出结果 + _this.words1 = _this.searchValue + _this.words2 = _this.searchText + + // 关闭语音 + plus.speech.stopRecognize(); + }, function(e){ + console.log('语音识别失败:'+JSON.stringify(e)); + }); + //#endif + // #ifdef H5 + alert("只有h5平台才有alert方法") + // #endif + + }, + //文字转语音 txtspeech(val, i) { @@ -642,21 +676,21 @@ // }).catch((err) => { // console.log(err) // }) - + ttWss({ data: val }).then(res => { if (res.code == 0) { - this.talkList[i].audio_file = res.data.mp3 - this.nums = this.talkList.length - 1 + this.talkList[i].audio_file = res.data.mp3 + this.nums = this.talkList.length - 1 this.nums = this.talkList.length - 1 } }).catch((err) => { console.log(err) }) - - + + }, //点击事件 @@ -668,6 +702,7 @@ }, longpress(e) { // console.log(e.touches[0].pageX) + this.voiceBegain() this.onFeedTap() this.touchT = new Date().getTime(); this.islong = true @@ -829,7 +864,7 @@ console.error(error) }) }, - + //删除本地录音文件 deletespeech() { this.btnStatus = 0 @@ -875,7 +910,7 @@ palyaudio(item) { this.palystatus = !this.palystatus - + if (!this.palystatus) { innerAudioContext.src = item.audio_file; innerAudioContext.play() diff --git a/pages/index/index2.vue b/pages/index/index2.vue new file mode 100644 index 0000000..de13cba --- /dev/null +++ b/pages/index/index2.vue @@ -0,0 +1,1927 @@ + + + + + \ No newline at end of file