diff --git a/hybrid/html/ai.html b/hybrid/html/ai.html index 8b69027..3ff5991 100755 --- a/hybrid/html/ai.html +++ b/hybrid/html/ai.html @@ -277,13 +277,9 @@ // 重置倒计时 seconds = 10; - console.log(text) - gaptime = setInterval(() => { - console.log(seconds, '倒计时') seconds--; if (voiceTxt.innerText) { - console.log('有 text 参数'); // 如果有 text 参数,打印 1 clearInterval(gaptime); gaptime = null; seconds = 10; @@ -293,7 +289,6 @@ if (!isCallbackExecuted) { clearTimeout(times); times = setTimeout(() => { - this.stop(); statusTxt.value = '正在听…'; const params = { msg: text }; @@ -473,9 +468,6 @@ } else if (seconds == 0){ clearInterval(gaptime); closeShibie(); - - // 重置 - location.reload(); return; } }, 1000); @@ -528,7 +520,6 @@ // 先静音即可处理解决(提前做交互) audioElement.muted = false; - audioElement.currentTime = 0; audioElement.pause(); @@ -657,37 +648,15 @@ // 监听播放技术 myAudio.addEventListener('ended', function() { console.log('音频播放已结束!'); - // 停止倒计时 - startRec.style.display = 'block'; - endRec.style.display = 'none'; - stopRec.style.display = 'none'; - statusTxt.value = ''; - voiceTxt.innerText = ''; - replayVideoSegment(0, 60); - hideModal() - // 播放结束重新开始监听 + replayVideoSegment(0, 60); + voice.stop(); startShibie(); }); Subtitles = ""; } - // 防抖 - function throttle(fn, wait) { - let lastTime = 0; // 上一次调用的时间 - - return function (...args) { - const now = Date.now(); // 当前时间 - - // 如果距离上次调用已经超过设定时间,则调用函数 - if (now - lastTime > wait) { - lastTime = now; // 更新上一次调用的时间 - fn.apply(this, args); // 以正确的`this`和参数调用函数 - } - }; - } - // 拿到的数据移除* function filterString(str, charsToRemove) { // 这里的正则表达式是通过将charsToRemove数组中的字符转换为字符类(character class)来构建的 diff --git a/hybrid/html/js/voice.js b/hybrid/html/js/voice.js index eae2b15..2cfd943 100755 --- a/hybrid/html/js/voice.js +++ b/hybrid/html/js/voice.js @@ -110,6 +110,7 @@ }; // 连接WebSocket connectWebSocket() { + console.log('连接WebSocket') return this.getWebSocketUrl().then(url => { let iatWS; if ('WebSocket' in window) { @@ -122,8 +123,11 @@ } this.webSocket = iatWS; this.setStatus('init'); + iatWS.onopen = e => { this.setStatus('ing'); + console.log('ws开启重新开始录音'); + // 重新开始录音 setTimeout(() => { this.webSocketSend(); @@ -140,6 +144,18 @@ }; }) }; + + + // 防抖函数 + debounce(func, wait) { + let timeout; + return function(...args) { + const context = this; + clearTimeout(timeout); + timeout = setTimeout(() => func.apply(context, args), wait); + }; + } + // 初始化浏览器录音 recorderInit() { // 创建音频环境 @@ -216,9 +232,10 @@ }; // 向webSocket发送数据(音频二进制数据经过Base64处理) webSocketSend() { + console.log('发送数据') if (this.webSocket.readyState !== 1) return false; // 音频数据 - const audioData = this.audioData.splice(0, 1280); + let audioData = this.audioData.splice(0, 1280); const params = { common: { app_id: this.appId, @@ -237,14 +254,17 @@ audio: this.toBase64(audioData) } }; + console.log(params, 'socket数据'); + // 发送数据 this.webSocket.send(JSON.stringify(params)); + this.handlerInterval = setInterval(() => { // websocket未连接 if (this.webSocket.readyState !== 1) { this.audioData = []; clearInterval(this.handlerInterval); - return false; + return false; }; if (this.audioData.length === 0) { if (this.status === 'end') { @@ -312,9 +332,10 @@ this.webSocket.close(); } }; + // 启动录音 recorderStart() { - if (!this.audioContext) { + if (!this.audioContext) { this.recorderInit(); } else { this.audioContext.resume(); @@ -340,8 +361,10 @@ this.setResultText({ resultText: '', resultTextTemp: '' }); }; // 停止 - stop() { + stop() { + console.log('停了停了停了停了停了停了停了停了停了停了'); this.recorderStop(); + this.webSocket.close(); }; }; })); \ No newline at end of file diff --git a/unpackage/cache/wgt/__UNI__24DA8DD/hybrid/html/ai.html b/unpackage/cache/wgt/__UNI__24DA8DD/hybrid/html/ai.html index bdf61c7..3ff5991 100644 --- a/unpackage/cache/wgt/__UNI__24DA8DD/hybrid/html/ai.html +++ b/unpackage/cache/wgt/__UNI__24DA8DD/hybrid/html/ai.html @@ -277,25 +277,19 @@ // 重置倒计时 seconds = 10; - console.log(text) - gaptime = setInterval(() => { - console.log(seconds, '倒计时') seconds--; if (voiceTxt.innerText) { - console.log('有 text 参数'); // 如果有 text 参数,打印 1 clearInterval(gaptime); gaptime = null; seconds = 10; // 3秒钟内没有说话,就自动关闭 if (text) { - statusTxt.value = '正在听…'; if (!isCallbackExecuted) { clearTimeout(times); times = setTimeout(() => { - this.stop(); - statusTxt.value = '正在说话'; + statusTxt.value = '正在听…'; const params = { msg: text }; @@ -474,9 +468,6 @@ } else if (seconds == 0){ clearInterval(gaptime); closeShibie(); - - // 重置 - location.reload(); return; } }, 1000); @@ -521,6 +512,7 @@ function startShibie() { /**开始识别**/ + statusTxt.value = '正在听…'; voiceTxt.innerText = ''; stopRec.textContent = '暂停'; @@ -528,7 +520,6 @@ // 先静音即可处理解决(提前做交互) audioElement.muted = false; - audioElement.currentTime = 0; audioElement.pause(); @@ -657,37 +648,15 @@ // 监听播放技术 myAudio.addEventListener('ended', function() { console.log('音频播放已结束!'); - // 停止倒计时 - startRec.style.display = 'block'; - endRec.style.display = 'none'; - stopRec.style.display = 'none'; - statusTxt.value = ''; - voiceTxt.innerText = ''; - replayVideoSegment(0, 60); - hideModal() - // 播放结束重新开始监听 + replayVideoSegment(0, 60); + voice.stop(); startShibie(); }); Subtitles = ""; } - // 防抖 - function throttle(fn, wait) { - let lastTime = 0; // 上一次调用的时间 - - return function (...args) { - const now = Date.now(); // 当前时间 - - // 如果距离上次调用已经超过设定时间,则调用函数 - if (now - lastTime > wait) { - lastTime = now; // 更新上一次调用的时间 - fn.apply(this, args); // 以正确的`this`和参数调用函数 - } - }; - } - // 拿到的数据移除* function filterString(str, charsToRemove) { // 这里的正则表达式是通过将charsToRemove数组中的字符转换为字符类(character class)来构建的 diff --git a/unpackage/cache/wgt/__UNI__24DA8DD/hybrid/html/js/voice.js b/unpackage/cache/wgt/__UNI__24DA8DD/hybrid/html/js/voice.js index eae2b15..2cfd943 100644 --- a/unpackage/cache/wgt/__UNI__24DA8DD/hybrid/html/js/voice.js +++ b/unpackage/cache/wgt/__UNI__24DA8DD/hybrid/html/js/voice.js @@ -110,6 +110,7 @@ }; // 连接WebSocket connectWebSocket() { + console.log('连接WebSocket') return this.getWebSocketUrl().then(url => { let iatWS; if ('WebSocket' in window) { @@ -122,8 +123,11 @@ } this.webSocket = iatWS; this.setStatus('init'); + iatWS.onopen = e => { this.setStatus('ing'); + console.log('ws开启重新开始录音'); + // 重新开始录音 setTimeout(() => { this.webSocketSend(); @@ -140,6 +144,18 @@ }; }) }; + + + // 防抖函数 + debounce(func, wait) { + let timeout; + return function(...args) { + const context = this; + clearTimeout(timeout); + timeout = setTimeout(() => func.apply(context, args), wait); + }; + } + // 初始化浏览器录音 recorderInit() { // 创建音频环境 @@ -216,9 +232,10 @@ }; // 向webSocket发送数据(音频二进制数据经过Base64处理) webSocketSend() { + console.log('发送数据') if (this.webSocket.readyState !== 1) return false; // 音频数据 - const audioData = this.audioData.splice(0, 1280); + let audioData = this.audioData.splice(0, 1280); const params = { common: { app_id: this.appId, @@ -237,14 +254,17 @@ audio: this.toBase64(audioData) } }; + console.log(params, 'socket数据'); + // 发送数据 this.webSocket.send(JSON.stringify(params)); + this.handlerInterval = setInterval(() => { // websocket未连接 if (this.webSocket.readyState !== 1) { this.audioData = []; clearInterval(this.handlerInterval); - return false; + return false; }; if (this.audioData.length === 0) { if (this.status === 'end') { @@ -312,9 +332,10 @@ this.webSocket.close(); } }; + // 启动录音 recorderStart() { - if (!this.audioContext) { + if (!this.audioContext) { this.recorderInit(); } else { this.audioContext.resume(); @@ -340,8 +361,10 @@ this.setResultText({ resultText: '', resultTextTemp: '' }); }; // 停止 - stop() { + stop() { + console.log('停了停了停了停了停了停了停了停了停了停了'); this.recorderStop(); + this.webSocket.close(); }; }; })); \ No newline at end of file diff --git a/unpackage/cache/wgt/__UNI__24DA8DD/manifest.json b/unpackage/cache/wgt/__UNI__24DA8DD/manifest.json index 178c46b..7f55a27 100644 --- a/unpackage/cache/wgt/__UNI__24DA8DD/manifest.json +++ b/unpackage/cache/wgt/__UNI__24DA8DD/manifest.json @@ -1 +1 @@ -{"@platforms":["android","iPhone","iPad"],"id":"__UNI__24DA8DD","name":"中鼎云医","version":{"name":"1.2.5","code":125},"description":"中鼎云医","launch_path":"__uniappview.html","developer":{"name":"","email":"","url":""},"permissions":{"VideoPlayer":{},"Record":{},"UniNView":{"description":"UniNView原生渲染"}},"plus":{"useragent":{"value":"uni-app","concatenate":true},"splashscreen":{"autoclose":true,"delay":0,"target":"id:1","waiting":true},"popGesture":"close","launchwebview":{"render":"always","id":"1","kernel":"WKWebview"},"statusbar":{"immersed":"supportedDevice","style":"dark","background":"#F8F8F8"},"usingComponents":true,"nvueStyleCompiler":"uni-app","compilerVersion":3,"distribute":{"screenOrientation":"landscape-primary","icons":{"android":{"hdpi":"icon-android-hdpi.png","xhdpi":"icon-android-xhdpi.png","xxhdpi":"icon-android-xxhdpi.png","xxxhdpi":"icon-android-xxxhdpi.png"},"ios":{"appstore":"unpackage/res/icons/1024x1024.png","ipad":{"app":"unpackage/res/icons/76x76.png","app@2x":"unpackage/res/icons/152x152.png","notification":"unpackage/res/icons/20x20.png","notification@2x":"unpackage/res/icons/40x40.png","proapp@2x":"unpackage/res/icons/167x167.png","settings":"unpackage/res/icons/29x29.png","settings@2x":"unpackage/res/icons/58x58.png","spotlight":"unpackage/res/icons/40x40.png","spotlight@2x":"unpackage/res/icons/80x80.png"},"iphone":{"app@2x":"unpackage/res/icons/120x120.png","app@3x":"unpackage/res/icons/180x180.png","notification@2x":"unpackage/res/icons/40x40.png","notification@3x":"unpackage/res/icons/60x60.png","settings@2x":"unpackage/res/icons/58x58.png","settings@3x":"unpackage/res/icons/87x87.png","spotlight@2x":"unpackage/res/icons/80x80.png","spotlight@3x":"unpackage/res/icons/120x120.png"},"prerendered":"false"}},"google":{"permissions":["","","","","","","","","","","","","","","",""],"packagename":"uni.UNI24DA8DD","aliasname":"platform","password":"aB6ADjKOYCOnZRmpzM7ptg==","keystore":"google-keystore.keystore","custompermissions":true},"apple":{"dSYMs":false,"plistcmds":["Add :UIFileSharingEnabled bool true"],"devices":"universal"},"plugins":{"ad":{},"audio":{"mp3":{"description":"Android平台录音支持MP3格式文件"}}},"debug":true,"syncDebug":true,"orientation":"portrait-primary"},"uniStatistics":{"enable":false},"allowsInlineMediaPlayback":true,"uni-app":{"compilerVersion":"4.15","control":"uni-v3","nvueCompiler":"uni-app","renderer":"auto","nvue":{"flex-direction":"column"},"nvueLaunchMode":"normal"},"launch_path":"__uniappview.html","adid":"123262070412"},"screenOrientation":["portrait-primary","portrait-secondary"]} \ No newline at end of file +{"@platforms":["android","iPhone","iPad"],"id":"__UNI__24DA8DD","name":"中鼎云医","version":{"name":"1.2.5","code":125},"description":"中鼎云医","launch_path":"__uniappview.html","developer":{"name":"","email":"","url":""},"permissions":{"VideoPlayer":{},"Record":{},"UniNView":{"description":"UniNView原生渲染"}},"plus":{"useragent":{"value":"uni-app","concatenate":true},"splashscreen":{"autoclose":true,"delay":0,"target":"id:1","waiting":true},"popGesture":"close","launchwebview":{"render":"always","id":"1","kernel":"WKWebview"},"statusbar":{"immersed":"supportedDevice","style":"dark","background":"#F8F8F8"},"usingComponents":true,"nvueStyleCompiler":"uni-app","compilerVersion":3,"distribute":{"screenOrientation":"landscape-primary","icons":{"android":{"hdpi":"icon-android-hdpi.png","xhdpi":"icon-android-xhdpi.png","xxhdpi":"icon-android-xxhdpi.png","xxxhdpi":"icon-android-xxxhdpi.png"},"ios":{"appstore":"unpackage/res/icons/1024x1024.png","ipad":{"app":"unpackage/res/icons/76x76.png","app@2x":"unpackage/res/icons/152x152.png","notification":"unpackage/res/icons/20x20.png","notification@2x":"unpackage/res/icons/40x40.png","proapp@2x":"unpackage/res/icons/167x167.png","settings":"unpackage/res/icons/29x29.png","settings@2x":"unpackage/res/icons/58x58.png","spotlight":"unpackage/res/icons/40x40.png","spotlight@2x":"unpackage/res/icons/80x80.png"},"iphone":{"app@2x":"unpackage/res/icons/120x120.png","app@3x":"unpackage/res/icons/180x180.png","notification@2x":"unpackage/res/icons/40x40.png","notification@3x":"unpackage/res/icons/60x60.png","settings@2x":"unpackage/res/icons/58x58.png","settings@3x":"unpackage/res/icons/87x87.png","spotlight@2x":"unpackage/res/icons/80x80.png","spotlight@3x":"unpackage/res/icons/120x120.png"},"prerendered":"false"}},"google":{"permissions":["","","","","","","","","","","","","","","",""],"packagename":"uni.UNI24DA8DD","aliasname":"platform","password":"aB6ADjKOYCOnZRmpzM7ptg==","keystore":"google-keystore.keystore","custompermissions":true},"apple":{"dSYMs":false,"devices":"universal"},"plugins":{"ad":{},"audio":{"mp3":{"description":"Android平台录音支持MP3格式文件"}}},"orientation":"portrait-primary"},"uniStatistics":{"enable":false},"allowsInlineMediaPlayback":true,"uni-app":{"compilerVersion":"4.15","control":"uni-v3","nvueCompiler":"uni-app","renderer":"auto","nvue":{"flex-direction":"column"},"nvueLaunchMode":"normal"},"launch_path":"__uniappview.html","adid":"123262070412"},"screenOrientation":["portrait-primary","portrait-secondary"]} \ No newline at end of file diff --git a/unpackage/dist/build/app-plus/hybrid/html/ai.html b/unpackage/dist/build/app-plus/hybrid/html/ai.html index 8b69027..3ff5991 100644 --- a/unpackage/dist/build/app-plus/hybrid/html/ai.html +++ b/unpackage/dist/build/app-plus/hybrid/html/ai.html @@ -277,13 +277,9 @@ // 重置倒计时 seconds = 10; - console.log(text) - gaptime = setInterval(() => { - console.log(seconds, '倒计时') seconds--; if (voiceTxt.innerText) { - console.log('有 text 参数'); // 如果有 text 参数,打印 1 clearInterval(gaptime); gaptime = null; seconds = 10; @@ -293,7 +289,6 @@ if (!isCallbackExecuted) { clearTimeout(times); times = setTimeout(() => { - this.stop(); statusTxt.value = '正在听…'; const params = { msg: text }; @@ -473,9 +468,6 @@ } else if (seconds == 0){ clearInterval(gaptime); closeShibie(); - - // 重置 - location.reload(); return; } }, 1000); @@ -528,7 +520,6 @@ // 先静音即可处理解决(提前做交互) audioElement.muted = false; - audioElement.currentTime = 0; audioElement.pause(); @@ -657,37 +648,15 @@ // 监听播放技术 myAudio.addEventListener('ended', function() { console.log('音频播放已结束!'); - // 停止倒计时 - startRec.style.display = 'block'; - endRec.style.display = 'none'; - stopRec.style.display = 'none'; - statusTxt.value = ''; - voiceTxt.innerText = ''; - replayVideoSegment(0, 60); - hideModal() - // 播放结束重新开始监听 + replayVideoSegment(0, 60); + voice.stop(); startShibie(); }); Subtitles = ""; } - // 防抖 - function throttle(fn, wait) { - let lastTime = 0; // 上一次调用的时间 - - return function (...args) { - const now = Date.now(); // 当前时间 - - // 如果距离上次调用已经超过设定时间,则调用函数 - if (now - lastTime > wait) { - lastTime = now; // 更新上一次调用的时间 - fn.apply(this, args); // 以正确的`this`和参数调用函数 - } - }; - } - // 拿到的数据移除* function filterString(str, charsToRemove) { // 这里的正则表达式是通过将charsToRemove数组中的字符转换为字符类(character class)来构建的 diff --git a/unpackage/dist/build/app-plus/hybrid/html/js/voice.js b/unpackage/dist/build/app-plus/hybrid/html/js/voice.js index eae2b15..2cfd943 100644 --- a/unpackage/dist/build/app-plus/hybrid/html/js/voice.js +++ b/unpackage/dist/build/app-plus/hybrid/html/js/voice.js @@ -110,6 +110,7 @@ }; // 连接WebSocket connectWebSocket() { + console.log('连接WebSocket') return this.getWebSocketUrl().then(url => { let iatWS; if ('WebSocket' in window) { @@ -122,8 +123,11 @@ } this.webSocket = iatWS; this.setStatus('init'); + iatWS.onopen = e => { this.setStatus('ing'); + console.log('ws开启重新开始录音'); + // 重新开始录音 setTimeout(() => { this.webSocketSend(); @@ -140,6 +144,18 @@ }; }) }; + + + // 防抖函数 + debounce(func, wait) { + let timeout; + return function(...args) { + const context = this; + clearTimeout(timeout); + timeout = setTimeout(() => func.apply(context, args), wait); + }; + } + // 初始化浏览器录音 recorderInit() { // 创建音频环境 @@ -216,9 +232,10 @@ }; // 向webSocket发送数据(音频二进制数据经过Base64处理) webSocketSend() { + console.log('发送数据') if (this.webSocket.readyState !== 1) return false; // 音频数据 - const audioData = this.audioData.splice(0, 1280); + let audioData = this.audioData.splice(0, 1280); const params = { common: { app_id: this.appId, @@ -237,14 +254,17 @@ audio: this.toBase64(audioData) } }; + console.log(params, 'socket数据'); + // 发送数据 this.webSocket.send(JSON.stringify(params)); + this.handlerInterval = setInterval(() => { // websocket未连接 if (this.webSocket.readyState !== 1) { this.audioData = []; clearInterval(this.handlerInterval); - return false; + return false; }; if (this.audioData.length === 0) { if (this.status === 'end') { @@ -312,9 +332,10 @@ this.webSocket.close(); } }; + // 启动录音 recorderStart() { - if (!this.audioContext) { + if (!this.audioContext) { this.recorderInit(); } else { this.audioContext.resume(); @@ -340,8 +361,10 @@ this.setResultText({ resultText: '', resultTextTemp: '' }); }; // 停止 - stop() { + stop() { + console.log('停了停了停了停了停了停了停了停了停了停了'); this.recorderStop(); + this.webSocket.close(); }; }; })); \ No newline at end of file diff --git a/unpackage/dist/dev/app-plus/hybrid/html/ai.html b/unpackage/dist/dev/app-plus/hybrid/html/ai.html index 8b69027..3ff5991 100644 --- a/unpackage/dist/dev/app-plus/hybrid/html/ai.html +++ b/unpackage/dist/dev/app-plus/hybrid/html/ai.html @@ -277,13 +277,9 @@ // 重置倒计时 seconds = 10; - console.log(text) - gaptime = setInterval(() => { - console.log(seconds, '倒计时') seconds--; if (voiceTxt.innerText) { - console.log('有 text 参数'); // 如果有 text 参数,打印 1 clearInterval(gaptime); gaptime = null; seconds = 10; @@ -293,7 +289,6 @@ if (!isCallbackExecuted) { clearTimeout(times); times = setTimeout(() => { - this.stop(); statusTxt.value = '正在听…'; const params = { msg: text }; @@ -473,9 +468,6 @@ } else if (seconds == 0){ clearInterval(gaptime); closeShibie(); - - // 重置 - location.reload(); return; } }, 1000); @@ -528,7 +520,6 @@ // 先静音即可处理解决(提前做交互) audioElement.muted = false; - audioElement.currentTime = 0; audioElement.pause(); @@ -657,37 +648,15 @@ // 监听播放技术 myAudio.addEventListener('ended', function() { console.log('音频播放已结束!'); - // 停止倒计时 - startRec.style.display = 'block'; - endRec.style.display = 'none'; - stopRec.style.display = 'none'; - statusTxt.value = ''; - voiceTxt.innerText = ''; - replayVideoSegment(0, 60); - hideModal() - // 播放结束重新开始监听 + replayVideoSegment(0, 60); + voice.stop(); startShibie(); }); Subtitles = ""; } - // 防抖 - function throttle(fn, wait) { - let lastTime = 0; // 上一次调用的时间 - - return function (...args) { - const now = Date.now(); // 当前时间 - - // 如果距离上次调用已经超过设定时间,则调用函数 - if (now - lastTime > wait) { - lastTime = now; // 更新上一次调用的时间 - fn.apply(this, args); // 以正确的`this`和参数调用函数 - } - }; - } - // 拿到的数据移除* function filterString(str, charsToRemove) { // 这里的正则表达式是通过将charsToRemove数组中的字符转换为字符类(character class)来构建的 diff --git a/unpackage/dist/dev/app-plus/hybrid/html/js/voice.js b/unpackage/dist/dev/app-plus/hybrid/html/js/voice.js index eae2b15..2cfd943 100644 --- a/unpackage/dist/dev/app-plus/hybrid/html/js/voice.js +++ b/unpackage/dist/dev/app-plus/hybrid/html/js/voice.js @@ -110,6 +110,7 @@ }; // 连接WebSocket connectWebSocket() { + console.log('连接WebSocket') return this.getWebSocketUrl().then(url => { let iatWS; if ('WebSocket' in window) { @@ -122,8 +123,11 @@ } this.webSocket = iatWS; this.setStatus('init'); + iatWS.onopen = e => { this.setStatus('ing'); + console.log('ws开启重新开始录音'); + // 重新开始录音 setTimeout(() => { this.webSocketSend(); @@ -140,6 +144,18 @@ }; }) }; + + + // 防抖函数 + debounce(func, wait) { + let timeout; + return function(...args) { + const context = this; + clearTimeout(timeout); + timeout = setTimeout(() => func.apply(context, args), wait); + }; + } + // 初始化浏览器录音 recorderInit() { // 创建音频环境 @@ -216,9 +232,10 @@ }; // 向webSocket发送数据(音频二进制数据经过Base64处理) webSocketSend() { + console.log('发送数据') if (this.webSocket.readyState !== 1) return false; // 音频数据 - const audioData = this.audioData.splice(0, 1280); + let audioData = this.audioData.splice(0, 1280); const params = { common: { app_id: this.appId, @@ -237,14 +254,17 @@ audio: this.toBase64(audioData) } }; + console.log(params, 'socket数据'); + // 发送数据 this.webSocket.send(JSON.stringify(params)); + this.handlerInterval = setInterval(() => { // websocket未连接 if (this.webSocket.readyState !== 1) { this.audioData = []; clearInterval(this.handlerInterval); - return false; + return false; }; if (this.audioData.length === 0) { if (this.status === 'end') { @@ -312,9 +332,10 @@ this.webSocket.close(); } }; + // 启动录音 recorderStart() { - if (!this.audioContext) { + if (!this.audioContext) { this.recorderInit(); } else { this.audioContext.resume(); @@ -340,8 +361,10 @@ this.setResultText({ resultText: '', resultTextTemp: '' }); }; // 停止 - stop() { + stop() { + console.log('停了停了停了停了停了停了停了停了停了停了'); this.recorderStop(); + this.webSocket.close(); }; }; })); \ No newline at end of file diff --git a/unpackage/release/apk/__UNI__24DA8DD__20241019002500.apk b/unpackage/release/apk/__UNI__24DA8DD__20241019002500.apk new file mode 100644 index 0000000..d315cb9 Binary files /dev/null and b/unpackage/release/apk/__UNI__24DA8DD__20241019002500.apk differ diff --git a/unpackage/release/apk/__UNI__24DA8DD__20241019112117.apk b/unpackage/release/apk/__UNI__24DA8DD__20241019112117.apk new file mode 100644 index 0000000..8e4f74e Binary files /dev/null and b/unpackage/release/apk/__UNI__24DA8DD__20241019112117.apk differ