Merge branch 'develop' of http://25.13.9.101:9000/K17_AITS/tra-app into develop
This commit is contained in:
@@ -8,8 +8,8 @@
|
||||
},
|
||||
{
|
||||
"bundleId" : "cn.com.jlbank.aits",
|
||||
"certificateFile" : "/Users/jlbank/Desktop/tra-app/certificate/ios/开发证书.p12",
|
||||
"certificateProfileFile" : "/Users/jlbank/Desktop/tra-app/certificate/ios/jiaixuedev.mobileprovision",
|
||||
"certificateFile" : "/Users/jlbank/Desktop/lx_uniapp/tra-app/certificate/ios/开发证书.p12",
|
||||
"certificateProfileFile" : "/Users/jlbank/Desktop/lx_uniapp/tra-app/certificate/ios/jiaixuedev.mobileprovision",
|
||||
"playground" : "standard",
|
||||
"runSignStatus" : 1,
|
||||
"type" : "uni-app:app-ios"
|
||||
|
||||
@@ -439,7 +439,6 @@
|
||||
8EED65A5198A626B000A4449 /* MapKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MapKit.framework; path = System/Library/Frameworks/MapKit.framework; sourceTree = SDKROOT; };
|
||||
8EED65A7198A6273000A4449 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; };
|
||||
A832515F2F67A4C2001DCF21 /* IJKMediaFrameworkWithSSL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IJKMediaFrameworkWithSSL.framework; path = ../SDK/Libs/IJKMediaFrameworkWithSSL.framework; sourceTree = "<group>"; };
|
||||
A86BA3852F63EBE400AF9A88 /* DCloudUTSFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = DCloudUTSFoundation.framework; path = ../SDK/Libs/DCloudUTSFoundation.framework; sourceTree = "<group>"; };
|
||||
A87E07812F6929AE00276C29 /* DCloudUTSFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = DCloudUTSFoundation.framework; sourceTree = "<group>"; };
|
||||
A87E07882F692EFF00276C29 /* DCUniBase.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = DCUniBase.framework; sourceTree = "<group>"; };
|
||||
A88BFB312E2600AC00E932EB /* DCSVProgressHUD.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = DCSVProgressHUD.bundle; path = ../SDK/Bundles/DCSVProgressHUD.bundle; sourceTree = "<group>"; };
|
||||
@@ -862,7 +861,6 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A832515F2F67A4C2001DCF21 /* IJKMediaFrameworkWithSSL.framework */,
|
||||
A86BA3852F63EBE400AF9A88 /* DCloudUTSFoundation.framework */,
|
||||
A8A511A32EEAAD4500D15560 /* libbz2.tbd */,
|
||||
A8A511A12EEAAD0500D15560 /* QuartzCore.framework */,
|
||||
A88BFB3A2E26030300E932EB /* Masonry.framework */,
|
||||
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
+2
-236
@@ -3970,226 +3970,6 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"kind": "Var",
|
||||
"name": "reuseInt32Array",
|
||||
"printedName": "reuseInt32Array",
|
||||
"children": [
|
||||
{
|
||||
"kind": "TypeNominal",
|
||||
"name": "Optional",
|
||||
"printedName": "DCloudUTSFoundation.Int32Array?",
|
||||
"children": [
|
||||
{
|
||||
"kind": "TypeNominal",
|
||||
"name": "Int32Array",
|
||||
"printedName": "DCloudUTSFoundation.Int32Array",
|
||||
"usr": "c:@M@DCloudUTSFoundation@objc(cs)Int32Array"
|
||||
}
|
||||
],
|
||||
"usr": "s:Sq"
|
||||
}
|
||||
],
|
||||
"declKind": "Var",
|
||||
"usr": "s:20unimoduleTyRecording15reuseInt32Array19DCloudUTSFoundation0eF0CSgvp",
|
||||
"mangledName": "$s20unimoduleTyRecording15reuseInt32Array19DCloudUTSFoundation0eF0CSgvp",
|
||||
"moduleName": "unimoduleTyRecording",
|
||||
"declAttributes": [
|
||||
"HasInitialValue",
|
||||
"HasStorage",
|
||||
"AccessControl"
|
||||
],
|
||||
"hasStorage": true,
|
||||
"accessors": [
|
||||
{
|
||||
"kind": "Accessor",
|
||||
"name": "Get",
|
||||
"printedName": "Get()",
|
||||
"children": [
|
||||
{
|
||||
"kind": "TypeNominal",
|
||||
"name": "Optional",
|
||||
"printedName": "DCloudUTSFoundation.Int32Array?",
|
||||
"children": [
|
||||
{
|
||||
"kind": "TypeNominal",
|
||||
"name": "Int32Array",
|
||||
"printedName": "DCloudUTSFoundation.Int32Array",
|
||||
"usr": "c:@M@DCloudUTSFoundation@objc(cs)Int32Array"
|
||||
}
|
||||
],
|
||||
"usr": "s:Sq"
|
||||
}
|
||||
],
|
||||
"declKind": "Accessor",
|
||||
"usr": "s:20unimoduleTyRecording15reuseInt32Array19DCloudUTSFoundation0eF0CSgvg",
|
||||
"mangledName": "$s20unimoduleTyRecording15reuseInt32Array19DCloudUTSFoundation0eF0CSgvg",
|
||||
"moduleName": "unimoduleTyRecording",
|
||||
"implicit": true,
|
||||
"accessorKind": "get"
|
||||
},
|
||||
{
|
||||
"kind": "Accessor",
|
||||
"name": "Set",
|
||||
"printedName": "Set()",
|
||||
"children": [
|
||||
{
|
||||
"kind": "TypeNominal",
|
||||
"name": "Void",
|
||||
"printedName": "()"
|
||||
},
|
||||
{
|
||||
"kind": "TypeNominal",
|
||||
"name": "Optional",
|
||||
"printedName": "DCloudUTSFoundation.Int32Array?",
|
||||
"children": [
|
||||
{
|
||||
"kind": "TypeNominal",
|
||||
"name": "Int32Array",
|
||||
"printedName": "DCloudUTSFoundation.Int32Array",
|
||||
"usr": "c:@M@DCloudUTSFoundation@objc(cs)Int32Array"
|
||||
}
|
||||
],
|
||||
"usr": "s:Sq"
|
||||
}
|
||||
],
|
||||
"declKind": "Accessor",
|
||||
"usr": "s:20unimoduleTyRecording15reuseInt32Array19DCloudUTSFoundation0eF0CSgvs",
|
||||
"mangledName": "$s20unimoduleTyRecording15reuseInt32Array19DCloudUTSFoundation0eF0CSgvs",
|
||||
"moduleName": "unimoduleTyRecording",
|
||||
"implicit": true,
|
||||
"accessorKind": "set"
|
||||
},
|
||||
{
|
||||
"kind": "Accessor",
|
||||
"name": "Modify",
|
||||
"printedName": "Modify()",
|
||||
"children": [
|
||||
{
|
||||
"kind": "TypeNominal",
|
||||
"name": "Void",
|
||||
"printedName": "()"
|
||||
}
|
||||
],
|
||||
"declKind": "Accessor",
|
||||
"usr": "s:20unimoduleTyRecording15reuseInt32Array19DCloudUTSFoundation0eF0CSgvM",
|
||||
"mangledName": "$s20unimoduleTyRecording15reuseInt32Array19DCloudUTSFoundation0eF0CSgvM",
|
||||
"moduleName": "unimoduleTyRecording",
|
||||
"implicit": true,
|
||||
"accessorKind": "_modify"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"kind": "Var",
|
||||
"name": "recordedPCMData",
|
||||
"printedName": "recordedPCMData",
|
||||
"children": [
|
||||
{
|
||||
"kind": "TypeNominal",
|
||||
"name": "Array",
|
||||
"printedName": "[Swift.UInt8]",
|
||||
"children": [
|
||||
{
|
||||
"kind": "TypeNominal",
|
||||
"name": "UInt8",
|
||||
"printedName": "Swift.UInt8",
|
||||
"usr": "s:s5UInt8V"
|
||||
}
|
||||
],
|
||||
"usr": "s:Sa"
|
||||
}
|
||||
],
|
||||
"declKind": "Var",
|
||||
"usr": "s:20unimoduleTyRecording15recordedPCMDataSays5UInt8VGvp",
|
||||
"mangledName": "$s20unimoduleTyRecording15recordedPCMDataSays5UInt8VGvp",
|
||||
"moduleName": "unimoduleTyRecording",
|
||||
"declAttributes": [
|
||||
"HasInitialValue",
|
||||
"HasStorage",
|
||||
"AccessControl"
|
||||
],
|
||||
"hasStorage": true,
|
||||
"accessors": [
|
||||
{
|
||||
"kind": "Accessor",
|
||||
"name": "Get",
|
||||
"printedName": "Get()",
|
||||
"children": [
|
||||
{
|
||||
"kind": "TypeNominal",
|
||||
"name": "Array",
|
||||
"printedName": "[Swift.UInt8]",
|
||||
"children": [
|
||||
{
|
||||
"kind": "TypeNominal",
|
||||
"name": "UInt8",
|
||||
"printedName": "Swift.UInt8",
|
||||
"usr": "s:s5UInt8V"
|
||||
}
|
||||
],
|
||||
"usr": "s:Sa"
|
||||
}
|
||||
],
|
||||
"declKind": "Accessor",
|
||||
"usr": "s:20unimoduleTyRecording15recordedPCMDataSays5UInt8VGvg",
|
||||
"mangledName": "$s20unimoduleTyRecording15recordedPCMDataSays5UInt8VGvg",
|
||||
"moduleName": "unimoduleTyRecording",
|
||||
"implicit": true,
|
||||
"accessorKind": "get"
|
||||
},
|
||||
{
|
||||
"kind": "Accessor",
|
||||
"name": "Set",
|
||||
"printedName": "Set()",
|
||||
"children": [
|
||||
{
|
||||
"kind": "TypeNominal",
|
||||
"name": "Void",
|
||||
"printedName": "()"
|
||||
},
|
||||
{
|
||||
"kind": "TypeNominal",
|
||||
"name": "Array",
|
||||
"printedName": "[Swift.UInt8]",
|
||||
"children": [
|
||||
{
|
||||
"kind": "TypeNominal",
|
||||
"name": "UInt8",
|
||||
"printedName": "Swift.UInt8",
|
||||
"usr": "s:s5UInt8V"
|
||||
}
|
||||
],
|
||||
"usr": "s:Sa"
|
||||
}
|
||||
],
|
||||
"declKind": "Accessor",
|
||||
"usr": "s:20unimoduleTyRecording15recordedPCMDataSays5UInt8VGvs",
|
||||
"mangledName": "$s20unimoduleTyRecording15recordedPCMDataSays5UInt8VGvs",
|
||||
"moduleName": "unimoduleTyRecording",
|
||||
"implicit": true,
|
||||
"accessorKind": "set"
|
||||
},
|
||||
{
|
||||
"kind": "Accessor",
|
||||
"name": "Modify",
|
||||
"printedName": "Modify()",
|
||||
"children": [
|
||||
{
|
||||
"kind": "TypeNominal",
|
||||
"name": "Void",
|
||||
"printedName": "()"
|
||||
}
|
||||
],
|
||||
"declKind": "Accessor",
|
||||
"usr": "s:20unimoduleTyRecording15recordedPCMDataSays5UInt8VGvM",
|
||||
"mangledName": "$s20unimoduleTyRecording15recordedPCMDataSays5UInt8VGvM",
|
||||
"moduleName": "unimoduleTyRecording",
|
||||
"implicit": true,
|
||||
"accessorKind": "_modify"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"kind": "Var",
|
||||
"name": "targetSampleRate",
|
||||
@@ -6260,31 +6040,17 @@
|
||||
"length": 5,
|
||||
"value": "false"
|
||||
},
|
||||
{
|
||||
"filePath": "\/Users\/jlbank\/Desktop\/111\/unimoduleTyRecording\/src\/index.swift",
|
||||
"kind": "IntegerLiteral",
|
||||
"offset": 7751,
|
||||
"length": 4,
|
||||
"value": "4800"
|
||||
},
|
||||
{
|
||||
"filePath": "\/Users\/jlbank\/Desktop\/111\/unimoduleTyRecording\/src\/index.swift",
|
||||
"kind": "Array",
|
||||
"offset": 7795,
|
||||
"length": 2,
|
||||
"value": "[]"
|
||||
},
|
||||
{
|
||||
"filePath": "\/Users\/jlbank\/Desktop\/111\/unimoduleTyRecording\/src\/index.swift",
|
||||
"kind": "FloatLiteral",
|
||||
"offset": 7836,
|
||||
"offset": 7736,
|
||||
"length": 7,
|
||||
"value": "16000.0"
|
||||
},
|
||||
{
|
||||
"filePath": "\/Users\/jlbank\/Desktop\/111\/unimoduleTyRecording\/src\/index.swift",
|
||||
"kind": "IntegerLiteral",
|
||||
"offset": 7876,
|
||||
"offset": 7776,
|
||||
"length": 1,
|
||||
"value": "1"
|
||||
}
|
||||
|
||||
-2
@@ -71,8 +71,6 @@ public var AudioErrors: [unimoduleTyRecording.AudioErrorCode : Swift.String]
|
||||
public var isRecording: Swift.Bool
|
||||
public var audioEngine: AVFAudio.AVAudioEngine?
|
||||
public var inputNode: AVFAudio.AVAudioInputNode?
|
||||
public var reuseInt32Array: DCloudUTSFoundation.Int32Array?
|
||||
public var recordedPCMData: [Swift.UInt8]
|
||||
public var targetSampleRate: Swift.Double
|
||||
public var channels: Foundation.NSNumber
|
||||
public var recordStartTime: Foundation.NSNumber?
|
||||
|
||||
-2
@@ -71,8 +71,6 @@ public var AudioErrors: [unimoduleTyRecording.AudioErrorCode : Swift.String]
|
||||
public var isRecording: Swift.Bool
|
||||
public var audioEngine: AVFAudio.AVAudioEngine?
|
||||
public var inputNode: AVFAudio.AVAudioInputNode?
|
||||
public var reuseInt32Array: DCloudUTSFoundation.Int32Array?
|
||||
public var recordedPCMData: [Swift.UInt8]
|
||||
public var targetSampleRate: Swift.Double
|
||||
public var channels: Foundation.NSNumber
|
||||
public var recordStartTime: Foundation.NSNumber?
|
||||
|
||||
+10
-10
@@ -22,15 +22,15 @@
|
||||
</data>
|
||||
<key>Modules/unimoduleTyRecording.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo</key>
|
||||
<data>
|
||||
QbjcvbPxe2SMBqPdoCza55av/Tw=
|
||||
TLOHHDzHkJ5T0ookGp0eUuKiAyU=
|
||||
</data>
|
||||
<key>Modules/unimoduleTyRecording.swiftmodule/arm64-apple-ios.abi.json</key>
|
||||
<data>
|
||||
Z7ggKmxb9JqzIhxdnP1xCbzzZ4k=
|
||||
pbmeWUh86qZBo+NDNLQTkugcS1Q=
|
||||
</data>
|
||||
<key>Modules/unimoduleTyRecording.swiftmodule/arm64-apple-ios.private.swiftinterface</key>
|
||||
<data>
|
||||
LJpDEMNwHf014zr2KuiiwfkstBo=
|
||||
3F+Z9ScbP7Joffio7FCaruBCwoM=
|
||||
</data>
|
||||
<key>Modules/unimoduleTyRecording.swiftmodule/arm64-apple-ios.swiftdoc</key>
|
||||
<data>
|
||||
@@ -38,11 +38,11 @@
|
||||
</data>
|
||||
<key>Modules/unimoduleTyRecording.swiftmodule/arm64-apple-ios.swiftinterface</key>
|
||||
<data>
|
||||
LJpDEMNwHf014zr2KuiiwfkstBo=
|
||||
3F+Z9ScbP7Joffio7FCaruBCwoM=
|
||||
</data>
|
||||
<key>Modules/unimoduleTyRecording.swiftmodule/arm64-apple-ios.swiftmodule</key>
|
||||
<data>
|
||||
Pin0pLehK8375qWP03Epfm9w+Pk=
|
||||
afsK4ngvO+GyKohHC+HTeaJlMQ4=
|
||||
</data>
|
||||
<key>config.json</key>
|
||||
<data>
|
||||
@@ -80,21 +80,21 @@
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
947SepgiPHcaEuic0DLG2gwt/FS8rF716Trb8QOlqlM=
|
||||
Eumt+b0A6MowWHNAl4LzHEqx8tqDes6Gkne6WMYV3no=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Modules/unimoduleTyRecording.swiftmodule/arm64-apple-ios.abi.json</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
B0HE4iiPSTwFN9Pz8MyiSw90PHoeoAGkINkAjKAquCE=
|
||||
Eg/gzUqHUsddFo7fv6D4oO57364iyyHCDeuVA3FBOyY=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Modules/unimoduleTyRecording.swiftmodule/arm64-apple-ios.private.swiftinterface</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
+ZduByY3uAsmQpDhqBuZyAWRwjgdV2xjsJkZUbrlw5Q=
|
||||
V39qYlvjQK7ofWRX95tTDt4mxPb23S3mMFWZi1LxJkA=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Modules/unimoduleTyRecording.swiftmodule/arm64-apple-ios.swiftdoc</key>
|
||||
@@ -108,14 +108,14 @@
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
+ZduByY3uAsmQpDhqBuZyAWRwjgdV2xjsJkZUbrlw5Q=
|
||||
V39qYlvjQK7ofWRX95tTDt4mxPb23S3mMFWZi1LxJkA=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Modules/unimoduleTyRecording.swiftmodule/arm64-apple-ios.swiftmodule</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
FRUEjsQO4p4SSBQv/tNb1cDT4XQpnurMRxgSUr0nPBI=
|
||||
vNu7jOeumiVckYl+2jb6jwGCh9aQAKf9KV4Vgrjrc6Y=
|
||||
</data>
|
||||
</dict>
|
||||
<key>config.json</key>
|
||||
|
||||
BIN
Binary file not shown.
@@ -1,4 +1,4 @@
|
||||
import { ErrorCode, ShowErrorTipOptions } from './touch-btn.types';
|
||||
import { ErrorMessageEnum, ShowErrorTipOptions } from './touch-btn.types';
|
||||
import { get_base_url } from '@/api/request.js';
|
||||
import { getPhoneEnvBool } from '@/common/common.js';
|
||||
const IsAndEnv = getPhoneEnvBool('AND')
|
||||
@@ -69,7 +69,7 @@ export const initWebSocket = (wsUrl : string) : Promise<UniApp.SocketTask> => {
|
||||
* @returns 固定返回false(保持原有返回值类型)
|
||||
*/
|
||||
export function showErrorTip(
|
||||
errorCode : ErrorCode,
|
||||
errorMsg : ErrorMessageEnum | string,
|
||||
options : ShowErrorTipOptions = {}
|
||||
) : boolean {
|
||||
// 解构可选参数,设置默认延迟时间为200ms
|
||||
@@ -78,7 +78,7 @@ export function showErrorTip(
|
||||
// 延迟显示对应的错误提示
|
||||
setTimeout(() => {
|
||||
uni.showToast({
|
||||
title: errorCode, // 直接使用枚举值作为提示文本
|
||||
title: errorMsg, // 直接使用枚举值作为提示文本
|
||||
icon: 'none'
|
||||
});
|
||||
}, delayTime); // 使用传入的延迟时间(或默认200ms)
|
||||
|
||||
@@ -24,7 +24,7 @@ export type VoiceToTextSubStatus =
|
||||
export type WorkModeType = 'both' | 'text-only' | 'voice-only' ;
|
||||
|
||||
/** 错误码枚举 - 直接映射提示文本 */
|
||||
export enum ErrorCode {
|
||||
export enum ErrorMessageEnum {
|
||||
// 网络错误提示
|
||||
NetworkError = '网络连接失败,请稍后再试!',
|
||||
// 录音时长过短提示
|
||||
|
||||
@@ -116,12 +116,13 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import * as TouchBtnImages from './touch-btn.images'; // 导出图片
|
||||
import { StatusType, VoiceToTextSubStatus, ErrorCode, WorkModeType } from './touch-btn.types';
|
||||
import { StatusType, VoiceToTextSubStatus, ErrorMessageEnum, WorkModeType } from './touch-btn.types';
|
||||
import type { TouchBtnEmits } from './touch-btn.types';
|
||||
import { wsUrl, bottomAreaTopBoundary, horizontalSplitX, initWebSocket, showErrorTip, vibrateLight } from './touch-btn';
|
||||
import { ref, computed, onMounted, nextTick, watch, reactive } from 'vue';
|
||||
import { onHide, onLaunch } from '@dcloudio/uni-app';
|
||||
import common, { setupKeyboardHeightListener, getToken } from '@/common/common';
|
||||
import { goto_login_fun } from '@/api/request.js';
|
||||
import { startAudioRecord, stopAudioRecord, preRequestRecordPermission } from '@/uni_modules/ty-recording';
|
||||
import { ProtocolCodec, MessageType, ControlCommand, ControlCode, ControlBody } from '@/common/protocolCodec';
|
||||
import permissionApi from '@/common/permission';
|
||||
@@ -212,14 +213,11 @@
|
||||
|
||||
const classes = [];
|
||||
isOutStatus.value === '02' && classes.push('is-out');
|
||||
(isOutStatus.value === '03' || status.value === 'voice_to_text' || status.value === 'send_over') &&
|
||||
classes.push('is-translate');
|
||||
(isOutStatus.value === '03' || status.value === 'voice_to_text' || status.value === 'send_over') && classes.push('is-translate');
|
||||
// 仅语音模式,01松手后要和03操作一样
|
||||
// isOutStatus.value === '01' && workMode.value === 'text-only' && status.value == 'voice_to_text' && classes.push('is-translate');
|
||||
voice_to_text_status.value !== '' && classes.push(voice_to_text_status.value);
|
||||
|
||||
return classes;
|
||||
// return ['is-translate','success' ];
|
||||
});
|
||||
const recordId = ref('');
|
||||
const allText = ref('');
|
||||
@@ -271,11 +269,8 @@
|
||||
if (props.canAnswer) return common.msg(props.canAnswerText);
|
||||
try {
|
||||
const state = await permissionApi.judgeIosPermission('record');
|
||||
if (state === 'not determined') {
|
||||
// 苹果专用
|
||||
preRequestRecordPermission();
|
||||
return;
|
||||
}
|
||||
console.log('state', state);
|
||||
if (state === 'not determined') return preRequestRecordPermission();
|
||||
} catch (e) {
|
||||
console.error('麦克风权限申请失败:', e);
|
||||
return;
|
||||
@@ -287,6 +282,7 @@
|
||||
tempText.value = '';
|
||||
allText.value = '';
|
||||
ossKey.value = '';
|
||||
|
||||
pressTimer = setTimeout(() => {
|
||||
if (!isRecording.value) {
|
||||
console.log('定时器被取消还是进入了');
|
||||
@@ -302,8 +298,101 @@
|
||||
touchPos.y = changedTouche.clientY;
|
||||
// 记录开始时间戳(毫秒)
|
||||
recordStartTime.value = Date.now();
|
||||
// 弹出录音界面
|
||||
startRecordingTimer(true); // 启动超长定时器
|
||||
popupRef.value.open(); // 弹出录音界面
|
||||
initWebSocket(wsUrl + '?summary=' + getToken())
|
||||
.then((socketTask) => {
|
||||
ws.value = socketTask;
|
||||
|
||||
ws.value.onMessage((res: { data: Uint8Array | ArrayBuffer }) => {
|
||||
try {
|
||||
const { msgType, body } = ProtocolCodec.unpack(res.data);
|
||||
if (msgType === MessageType.TEXT_MESSAGE) {
|
||||
tempText.value = '';
|
||||
allText.value = allText.value + body;
|
||||
} else if (msgType === MessageType.IDENTITY) {
|
||||
console.log("错误消息", body);
|
||||
const _errorBody = body as {code:number,msg:string };
|
||||
const recordDurationMs = Date.now() - recordStartTime.value;
|
||||
if(_errorBody?.code === 2) { // 认证错误,实际是登录失效
|
||||
closeWS();
|
||||
goto_login_fun();
|
||||
stopAudioRecord(); // 关掉录音
|
||||
setTimeout(() => closePopup, Math.max(700 - recordDurationMs, 0));
|
||||
return;
|
||||
} else if(_errorBody?.code === 1) {
|
||||
if (!isRecording.value) {
|
||||
ws.value = null;
|
||||
wsStatus.value = false;
|
||||
return;
|
||||
}
|
||||
console.log('开启语音');
|
||||
wsStatus.value = true;
|
||||
startRecordingTimer(true); // 启动超长定时器
|
||||
} else if(_errorBody?.code === 3) { // 路数不够等问题
|
||||
closeWS();
|
||||
stopAudioRecord(); // 关掉录音
|
||||
showErrorTip(_errorBody?.msg ?? '请稍后再试!');
|
||||
|
||||
setTimeout(() => closePopup, Math.max(700 - recordDurationMs, 0));
|
||||
}
|
||||
} 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();
|
||||
tempText.value = ''
|
||||
}
|
||||
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('网络出现问题');
|
||||
});
|
||||
startAudioRecord({
|
||||
onFrame: (pcmData: any) => {
|
||||
if (wsStatus.value && ws.value) {
|
||||
@@ -316,7 +405,6 @@
|
||||
// 发送完成后清空队列
|
||||
voiceQueue = [];
|
||||
}
|
||||
// 再发送当前帧的音频数据
|
||||
ws.value.send({
|
||||
data: ProtocolCodec.pack(MessageType.AUDIO_DATA, pcmData)
|
||||
});
|
||||
@@ -327,85 +415,7 @@
|
||||
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();
|
||||
tempText.value = ''
|
||||
}
|
||||
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);
|
||||
console.log('WS连接成功', isRecording.value);
|
||||
},
|
||||
onStop: () => {
|
||||
console.log('关闭');
|
||||
@@ -417,17 +427,19 @@
|
||||
}
|
||||
}
|
||||
});
|
||||
}, 120);
|
||||
}, 70);
|
||||
};
|
||||
|
||||
// 结束录音
|
||||
const closePopup = () => {
|
||||
if (voiceTimer) clearTimeout(voiceTimer);
|
||||
isRecording.value = false;
|
||||
popupRef.value.close();
|
||||
};
|
||||
// 结束ws
|
||||
const closeWS = () => {
|
||||
startRecordingTimer(false);
|
||||
console.log('ws.value', ws.value, wsStatus.value);
|
||||
if (ws.value) {
|
||||
ws.value.close({
|
||||
code: 1000,
|
||||
@@ -443,11 +455,14 @@
|
||||
|
||||
const stopRecord = async (errrStatus = '') => {
|
||||
console.log('松手stopRecord', pressTimer, isRecording.value, status.value);
|
||||
// 核心:计算录音总时长(毫秒转秒,保留1位小数)
|
||||
const recordDurationMs = Date.now() - recordStartTime.value;
|
||||
if (pressTimer) {
|
||||
clearTimeout(pressTimer);
|
||||
console.log('取消一个存在的定时器');
|
||||
pressTimer = null;
|
||||
isRecording.value = false;
|
||||
setTimeout(() => closePopup, Math.max(700 - recordDurationMs, 0));
|
||||
setTimeout(() => {
|
||||
status.value = 'default';
|
||||
}, 50);
|
||||
@@ -459,8 +474,7 @@
|
||||
closePopup();
|
||||
return;
|
||||
}
|
||||
// 核心:计算录音总时长(毫秒转秒,保留1位小数)
|
||||
const recordDurationMs = Date.now() - recordStartTime.value;
|
||||
|
||||
console.log('recordDurationMs', recordDurationMs);
|
||||
// 拖动到转文字按钮上抬手或者仅文字模式的发送也强行算他转文字
|
||||
const _isOutStatus = workMode.value === 'text-only' && isOutStatus.value === '01' ? '03' : isOutStatus.value;
|
||||
@@ -518,7 +532,7 @@
|
||||
} else if (recordDurationMs <= props.minRecordDuration) {
|
||||
console.log('进入这里了', status.value);
|
||||
if (_isOutStatus !== '02') {
|
||||
showErrorTip(ErrorCode.ShortRecord);
|
||||
showErrorTip(ErrorMessageEnum.ShortRecord);
|
||||
}
|
||||
setTimeout(() => {
|
||||
status.value = 'send_over'; // 设置成发送完成
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"deploymentTarget": "35"
|
||||
"deploymentTarget": "13"
|
||||
}
|
||||
|
||||
@@ -11,9 +11,6 @@ let isRecording = false;
|
||||
let audioEngine: AVAudioEngine | null = null;
|
||||
//音频输入节点(全局变量,避免被释放)
|
||||
let inputNode: AVAudioInputNode | null = null;
|
||||
// 新增:缓存录制的所有Int16 PCM数据
|
||||
let recordedPCMData: UInt8[] = [];
|
||||
// 3. 保存完整PCM数据到文件
|
||||
const targetSampleRate:Double = 16000.0; // 和采集时的目标格式一致
|
||||
const channels = 1; // 实际以采集时的声道数为准(可从inputFormat获取)
|
||||
// 新增:录音启动时间戳(毫秒)
|
||||
@@ -28,11 +25,7 @@ export function preRequestRecordPermission(callback?: (granted: boolean) => void
|
||||
|
||||
try {
|
||||
// 1. 配置基础音频会话(仅为权限申请,用record类别)
|
||||
UTSiOS.try(audioSession.setCategory(
|
||||
AVAudioSession.Category.record,
|
||||
mode=AVAudioSession.Mode.default
|
||||
));
|
||||
|
||||
UTSiOS.try(audioSession.setCategory(AVAudioSession.Category.record));
|
||||
// 2. 激活会话(权限申请建议激活,避免部分设备弹窗不触发)
|
||||
UTSiOS.try(audioSession.setActive(true));
|
||||
|
||||
@@ -40,12 +33,8 @@ export function preRequestRecordPermission(callback?: (granted: boolean) => void
|
||||
audioSession.requestRecordPermission((granted: boolean) => {
|
||||
console.log("预申请麦克风权限结果:", granted);
|
||||
|
||||
// 4. 权限申请完成后,立即停用会话(核心:释放资源)
|
||||
try {
|
||||
UTSiOS.try(audioSession.setActive(
|
||||
false,
|
||||
options= AVAudioSession.SetActiveOptions.notifyOthersOnDeactivation
|
||||
));
|
||||
UTSiOS.try(audioSession.setActive(false));
|
||||
} catch (e) {
|
||||
console.warn("预申请后停用音频会话失败:", e);
|
||||
}
|
||||
@@ -72,11 +61,7 @@ export function startAudioRecord(options: StartAudioRecordOptions){
|
||||
// 获取 iOS 系统的音频会话单例对象。
|
||||
const audioSession = AVAudioSession.sharedInstance();
|
||||
// 设置音频会话的类别、模式和附加选项,定义 App 的音频行为。
|
||||
UTSiOS.try(audioSession.setCategory(
|
||||
AVAudioSession.Category.playAndRecord,
|
||||
mode=AVAudioSession.Mode.spokenAudio,
|
||||
options= AVAudioSession.CategoryOptions.duckOthers // 可选:其他音频静音
|
||||
));
|
||||
UTSiOS.try(audioSession.setCategory(AVAudioSession.Category.record));
|
||||
UTSiOS.try(audioSession.setActive(true));
|
||||
isRecording = true;
|
||||
audioSession.requestRecordPermission((granted: boolean) => {
|
||||
@@ -84,7 +69,7 @@ export function startAudioRecord(options: StartAudioRecordOptions){
|
||||
try {
|
||||
UTSiOS.try(audioSession.setActive(false, options= AVAudioSession.SetActiveOptions.notifyOthersOnDeactivation));
|
||||
} catch (e) {
|
||||
console.warn("停用音频会话失败:", e);
|
||||
|
||||
}
|
||||
// 2. 重置状态
|
||||
isRecording = false;
|
||||
@@ -118,8 +103,7 @@ export function startAudioRecord(options: StartAudioRecordOptions){
|
||||
bufferSize= 2048, // 缓冲区大小,常用 1024/2048
|
||||
format= inputFormat, // 音频格式
|
||||
block=(buffer: AVAudioPCMBuffer, time: any) => {
|
||||
const frameLen = buffer.frameLength as number;
|
||||
const inputFrameLen = frameLen as Double;
|
||||
const inputFrameLen = Double(buffer.frameLength);
|
||||
const sampleRateRatio = targetSampleRate / inputFormat.sampleRate;
|
||||
const outputFrameCounta = inputFrameLen * sampleRateRatio
|
||||
const outputFrameCount = AVAudioFrameCount(outputFrameCounta);
|
||||
|
||||
Reference in New Issue
Block a user