diff --git a/.env.development b/.env.development index 4da586c0..ba6775df 100644 --- a/.env.development +++ b/.env.development @@ -2,10 +2,10 @@ ENV = 'development' # 'development' -VITE_APP_BASE_API_Url = 'https://aits.jlbank.com.cn:7001' +#VITE_APP_BASE_API_Url = 'https://aits.jlbank.com.cn:7001' -#VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7001' +VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7003' # DEV diff --git a/Android/.gradle/8.11/executionHistory/executionHistory.bin b/Android/.gradle/8.11/executionHistory/executionHistory.bin index ec16b614..591b34bd 100644 Binary files a/Android/.gradle/8.11/executionHistory/executionHistory.bin and b/Android/.gradle/8.11/executionHistory/executionHistory.bin differ diff --git a/Android/.gradle/8.11/executionHistory/executionHistory.lock b/Android/.gradle/8.11/executionHistory/executionHistory.lock index c26f2acb..c764d349 100644 Binary files a/Android/.gradle/8.11/executionHistory/executionHistory.lock and b/Android/.gradle/8.11/executionHistory/executionHistory.lock differ diff --git a/Android/.gradle/8.11/fileHashes/fileHashes.bin b/Android/.gradle/8.11/fileHashes/fileHashes.bin index e74f52f7..dae4d467 100644 Binary files a/Android/.gradle/8.11/fileHashes/fileHashes.bin and b/Android/.gradle/8.11/fileHashes/fileHashes.bin differ diff --git a/Android/.gradle/8.11/fileHashes/fileHashes.lock b/Android/.gradle/8.11/fileHashes/fileHashes.lock index 6b50f584..3cbe5fd2 100644 Binary files a/Android/.gradle/8.11/fileHashes/fileHashes.lock and b/Android/.gradle/8.11/fileHashes/fileHashes.lock differ diff --git a/Android/.gradle/8.11/fileHashes/resourceHashesCache.bin b/Android/.gradle/8.11/fileHashes/resourceHashesCache.bin index 6a282d63..e9330e9a 100644 Binary files a/Android/.gradle/8.11/fileHashes/resourceHashesCache.bin and b/Android/.gradle/8.11/fileHashes/resourceHashesCache.bin differ diff --git a/Android/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/Android/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 5c8ec4b0..277a0847 100644 Binary files a/Android/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/Android/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/Android/.gradle/buildOutputCleanup/outputFiles.bin b/Android/.gradle/buildOutputCleanup/outputFiles.bin index aa4b9181..d04d6a81 100644 Binary files a/Android/.gradle/buildOutputCleanup/outputFiles.bin and b/Android/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/Android/.gradle/config.properties b/Android/.gradle/config.properties index 75deeafc..134d93ab 100644 --- a/Android/.gradle/config.properties +++ b/Android/.gradle/config.properties @@ -1,2 +1,2 @@ -#Sun Mar 08 15:29:09 CST 2026 -java.home=F\:\\Android Studio\\jbr +#Mon Mar 09 08:55:18 CST 2026 +java.home=C\:\\Program Files\\Android\\Android Studio\\jbr diff --git a/Android/.gradle/file-system.probe b/Android/.gradle/file-system.probe index 92e27631..d2ceeb1e 100644 Binary files a/Android/.gradle/file-system.probe and b/Android/.gradle/file-system.probe differ diff --git a/src/components/touch-btn/touch-btn.ts b/src/components/touch-btn/touch-btn.ts index faa3bcf5..9e4f8e95 100644 --- a/src/components/touch-btn/touch-btn.ts +++ b/src/components/touch-btn/touch-btn.ts @@ -3,13 +3,10 @@ import { get_base_url } from '@/api/request.js'; import { getPhoneEnvBool } from '@/common/common.js'; const IsAndEnv = getPhoneEnvBool('AND') -// const url = '/trapractice/voiceCallSocket/voiceCall' -// const url = '/traapp/voiceTransSocket/open'; -// const url = '/traapp/asrAiModelSocket/open'; const url = '/traapp/asrAiModelSocket/open'; const _baseUrl = get_base_url(url).split('http').join('ws'); -// export const wsUrl = _baseUrl + url ; -export const wsUrl = 'ws://10.10.10.4:8000/ws/asr'; +export const wsUrl = _baseUrl + url; +// export const wsUrl = 'ws://10.10.10.4:8000/ws/asr'; const windowInfo = uni.getWindowInfo(); // 安全区域信息 const safeArea = windowInfo.safeArea; @@ -44,7 +41,7 @@ export const initWebSocket = (wsUrl : string) : Promise => { const onOpenHandler = (res) => { resolve(ws); }; - + // 4. 监听连接错误(出错时reject) const onErrorHandler = (err) => { console.log('WS连接错误', err, wsUrl); diff --git a/src/components/touch-btn/touch-btn.vue b/src/components/touch-btn/touch-btn.vue index 2fea1c9a..3f63963d 100644 --- a/src/components/touch-btn/touch-btn.vue +++ b/src/components/touch-btn/touch-btn.vue @@ -214,6 +214,7 @@ const tempText = ref(''); const inputText = ref(''); const ossKey = ref(''); + let voiceQueue = []; // 记录 按下移动位置 const touchPos = reactive({ x: 0, y: 0 }); // 是否录音中 @@ -274,68 +275,7 @@ tempText.value = ''; allText.value = ''; ossKey.value = ''; - console.log('开启语音'); - initWebSocket(wsUrl + '?summary=' + getToken()) - .then((socketTask) => { - if (!isRecording.value) { - ws.value = null; - wsStatus.value = false; - return; - } - ws.value = socketTask; - wsStatus.value = true; - console.log('WS连接成功', isRecording.value, ); - ws.value.onMessage((res: { data: Uint8Array | ArrayBuffer }) => { - try { - const { msgType, body } = ProtocolCodec.unpack(res.data); - console.log('msgType', msgType, body); - if (msgType === MessageType.TEXT_MESSAGE) { - tempText.value = ''; - allText.value = allText.value + body; - } else if (msgType === MessageType.TIP_MESSAGE) { - tempText.value += body as string; - } else if (msgType === MessageType.CONTROL_CMD) { - // 返回结束消息 - const controlBody = body as ControlBody; - if (controlBody.type === ControlCode.SERVER_TO_FRONT_OVER) { - console.log('识别结束', controlBody, voice_to_text_status.value); - // 如果不等于init说明已经超时,被超时函数处理完了,这里即使返回也不做处理 - if (status.value === 'voice_to_text' && voice_to_text_status.value !== 'init') return; - if (status.value === 'send_over') return; - // 时间太短,关掉的时候就处理了,这里不处理 - const recordDurationMs = Date.now() - recordStartTime.value; - if (recordDurationMs <= props.minRecordDuration) return; - closeWS() - status.value = 'send_over'; // 设置成发送完成 - if (voiceTimer) clearTimeout(voiceTimer); - // 设置识别结果 - voice_to_text_status.value = controlBody?.txt === '' ? 'failed' : 'success'; - // 取值出来 - ossKey.value = controlBody?.ossKey || ''; - if (typeof controlBody?.txt === 'string') { - allText.value = controlBody.txt.trim(); - } - const _isOutStatus = - workMode.value === 'text-only' && isOutStatus.value === '01' ? '03' : isOutStatus.value; - // 只有模式为01的时候才发送出去 - if (_isOutStatus === '01') { - emit('submitVoice', { - ossKey: ossKey.value, - text: allText.value, - recordId: recordId.value - }); - } - } - } - } catch (e) { - console.log('后端发来的信息有问题', e, res.data); - } - }); - }) - .catch(() => { - stopRecord('networkError'); - console.log('网络出现问题'); - }); + pressTimer = setTimeout(() => { if (!isRecording.value) { console.log('定时器被取消还是进入了'); @@ -352,18 +292,108 @@ // 记录开始时间戳(毫秒) recordStartTime.value = Date.now(); // 弹出录音界面 - startRecordingTimer(true) // 启动超长定时器 + startRecordingTimer(true); // 启动超长定时器 startAudioRecord({ onFrame: (pcmData: any) => { - console.log('msgType', pcmData.length, !!(wsStatus.value && ws.value)); if (wsStatus.value && ws.value) { - ws.value.send({ data: ProtocolCodec.pack(MessageType.AUDIO_DATA, pcmData) }); + if (voiceQueue.length > 0) { + voiceQueue.forEach((cachedData) => { + ws.value.send({ + data: ProtocolCodec.pack(MessageType.AUDIO_DATA, cachedData) + }); + }); + // 发送完成后清空队列 + voiceQueue = []; + } + // 再发送当前帧的音频数据 + ws.value.send({ + data: ProtocolCodec.pack(MessageType.AUDIO_DATA, pcmData) + }); + } else { + voiceQueue.push(pcmData) } }, onStart: (res: any) => { console.log('启动', res); recordId.value = res.recordId ?? ''; popupRef.value.open(); + console.log('开启语音'); + setTimeout(() => { + initWebSocket(wsUrl + '?summary=' + getToken()) + .then((socketTask) => { + if (!isRecording.value) { + ws.value = null; + wsStatus.value = false; + return; + } + ws.value = socketTask; + wsStatus.value = true; + console.log('WS连接成功', isRecording.value); + ws.value.onMessage((res: { data: Uint8Array | ArrayBuffer }) => { + try { + const { msgType, body } = ProtocolCodec.unpack(res.data); + console.log('msgType', msgType, body); + if (msgType === MessageType.TEXT_MESSAGE) { + tempText.value = ''; + allText.value = allText.value + body; + } else if (msgType === MessageType.TIP_MESSAGE) { + tempText.value += body as string; + } else if (msgType === MessageType.CONTROL_CMD) { + // 返回结束消息 + const controlBody = body as ControlBody; + if (controlBody.type === ControlCode.SERVER_TO_FRONT_OVER) { + console.log( + '识别结束', + controlBody, + voice_to_text_status.value, + status.value, + voice_to_text_status.value + ); + // 如果不等于init说明已经超时,被超时函数处理完了,这里即使返回也不做处理 + if ( + status.value === 'voice_to_text' && + voice_to_text_status.value !== 'init' + ) + return; + if (status.value === 'send_over') return; + // 时间太短,关掉的时候就处理了,这里不处理 + const recordDurationMs = Date.now() - recordStartTime.value; + if (recordDurationMs <= props.minRecordDuration) return; + closeWS(); + status.value = 'send_over'; // 设置成发送完成 + if (voiceTimer) clearTimeout(voiceTimer); + // 设置识别结果 + voice_to_text_status.value = controlBody?.txt === '' ? 'failed' : 'success'; + // 取值出来 + ossKey.value = controlBody?.ossKey || ''; + if (typeof controlBody?.txt === 'string') { + allText.value = controlBody.txt.trim(); + } + const _isOutStatus = + workMode.value === 'text-only' && isOutStatus.value === '01' + ? '03' + : isOutStatus.value; + // 只有模式为01的时候才发送出去 + console.log('只有模式为01的时候才发送出去', controlBody); + if (_isOutStatus === '01') { + emit('submitVoice', { + ossKey: ossKey.value, + text: allText.value, + recordId: recordId.value + }); + } + } + } + } catch (e) { + console.log('后端发来的信息有问题', e, res.data); + } + }); + }) + .catch(() => { + stopRecord('networkError'); + console.log('网络出现问题'); + }); + }, 200); }, onStop: () => { console.log('关闭'); @@ -380,7 +410,7 @@ // 结束录音 const closePopup = () => { - startRecordingTimer(false) + startRecordingTimer(false); isRecording.value = false; popupRef.value.close(); }; @@ -393,6 +423,7 @@ complete: () => { console.log('挂断Ws'); wsStatus.value = false; + ws.value = null; } }); } @@ -406,7 +437,7 @@ pressTimer = null; isRecording.value = false; setTimeout(() => { - status.value = 'default' + status.value = 'default'; }, 50); return; } diff --git a/src/components/touch-btn2/touch-btn.images.ts b/src/components/touch-btn2/touch-btn.images.ts deleted file mode 100644 index 500a7104..00000000 --- a/src/components/touch-btn2/touch-btn.images.ts +++ /dev/null @@ -1,6 +0,0 @@ -// components/touch-btn/touch-btn.images.ts -// 统一导出所有需要的图片资源 -export { default as cancelBtn } from '@/static/images/course/cancel.png'; -export { default as cancelActiveBtn } from '@/static/images/course/cancel-active.png'; -export { default as translateBtn } from '@/static/images/course/translate.png'; -export { default as translateActiveBtn } from '@/static/images/course/translate-active.png'; \ No newline at end of file diff --git a/src/components/touch-btn2/touch-btn.ts b/src/components/touch-btn2/touch-btn.ts deleted file mode 100644 index b5802764..00000000 --- a/src/components/touch-btn2/touch-btn.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { get_base_url } from '@/api/request.js'; -// const url = '/trapractice/voiceCallSocket/voiceCall' -// const url = '/traapp/voiceTransSocket/open'; -const url = '/traapp/voiceAiModelSocket/open'; -const _baseUrl = get_base_url(url).split('http').join('ws'); -export const wsUrl = _baseUrl + url; -const windowInfo = uni.getWindowInfo(); -// 安全区域信息 -const safeArea = windowInfo.safeArea; -// 按钮高度 -const btnHeight = (windowInfo.screenWidth / 750) * 234; -// 按钮的顶部边界 -export const bottomAreaTopBoundary = safeArea.bottom - btnHeight; -// 屏幕横向分割线 -export const horizontalSplitX = safeArea.right / 2; \ No newline at end of file diff --git a/src/components/touch-btn2/touch-btn.types.ts b/src/components/touch-btn2/touch-btn.types.ts deleted file mode 100644 index e88d046c..00000000 --- a/src/components/touch-btn2/touch-btn.types.ts +++ /dev/null @@ -1 +0,0 @@ -export type StatusType = 'voice' | 'input' | 'text'; \ No newline at end of file diff --git a/src/components/touch-btn2/touch-btn.vue b/src/components/touch-btn2/touch-btn.vue deleted file mode 100644 index f082de22..00000000 --- a/src/components/touch-btn2/touch-btn.vue +++ /dev/null @@ -1,541 +0,0 @@ - - - - - diff --git a/上架信息/应用上架信息.xlsx b/上架信息/应用上架信息.xlsx index 777738fb..65134217 100644 Binary files a/上架信息/应用上架信息.xlsx and b/上架信息/应用上架信息.xlsx differ