From: liangzhenying <867174124@qq.com> Date: Wed, 31 Dec 2025 09:56:03 +0000 (+0800) Subject: 自定义eq调试 X-Git-Tag: 1.0.2~12 X-Git-Url: http://git.snicker.com.cn/sitemap.xml?a=commitdiff_plain;h=f9ee03003ef788abc086e59007e3f22ec030e28f;p=mirrors%2FShenYin.git 自定义eq调试 --- diff --git a/DeepChordsSdk_iOS/DeepChordsSdk/Example/DeepChordsSdk/DCBleRecord.swift b/DeepChordsSdk_iOS/DeepChordsSdk/Example/DeepChordsSdk/DCBleRecord.swift index b6bf5ca..d2eae43 100644 --- a/DeepChordsSdk_iOS/DeepChordsSdk/Example/DeepChordsSdk/DCBleRecord.swift +++ b/DeepChordsSdk_iOS/DeepChordsSdk/Example/DeepChordsSdk/DCBleRecord.swift @@ -48,6 +48,9 @@ public class DCBleRecord { } func setupRecord(){ + // 通话录音声道数。1:单声道 ;2:⽴体声;默认单声道 + StarburstConfig.shared().callRecordChannel = 1 + let config = StarburstAsrConfig() config.isTranslate = isTranslate config.fromLanguage = fromLanguage diff --git a/DeepChordsSdk_iOS/DeepChordsSdk/Example/DeepChordsSdk/DCCallRecord.swift b/DeepChordsSdk_iOS/DeepChordsSdk/Example/DeepChordsSdk/DCCallRecord.swift index a6811bd..48c6ba8 100644 --- a/DeepChordsSdk_iOS/DeepChordsSdk/Example/DeepChordsSdk/DCCallRecord.swift +++ b/DeepChordsSdk_iOS/DeepChordsSdk/Example/DeepChordsSdk/DCCallRecord.swift @@ -21,24 +21,30 @@ public class DCCallRecord { public var ttsFormat = "mp3" /// 识别回调 public var asrCallback:((String)->Void)? + /// 对方识别回调 + public var asrOtherCallback:((String)->Void)? /// 状态码回调 public var codeCallback:((Int)->Void)? /// 录音文件回调 public var filePathCallBack:((String?)->Void)? - /// 设置录音文件路径 - public var filePath:String? + /// opus回调 + public var opusCallBack:((Data)->Void)? var asrList : [(String,Int)] = [] var asrText = "" - + var asrOtherList : [(String,Int)] = [] + var asrOtherText = "" init() { setupRecord() } func setupRecord(){ + // 通话录音声道数。1:单声道 ;2:⽴体声;默认单声道 + StarburstConfig.shared().callRecordChannel = 2 + let config = StarburstAsrConfig() config.isTranslate = isTranslate config.fromLanguage = fromLanguage @@ -46,27 +52,47 @@ public class DCCallRecord { config.isTTs = isTTs config.ttsFormat = ttsFormat - StarburstSdk.shared().setupDeviceRecord(with: filePath, asrConfig: config) { config in + StarburstSdk.shared().setupDeviceRecord(with: nil, asrConfig: config) { config in DCLogger.debug("录音类型 \(config!.type == 0x00 ? "实时录音" : "通话录音")") } recognizeText: { [weak self] model in guard let self = self else {return} guard let model = model else {return} - + DCLogger.debug(model.channel,"asr =",model.textResult) if let text = model.textResult,!text.isEmpty{ - DCLogger.debug("asr = \(text)") - let msg = asrList.firstIndex (where: { (str,idx) in - return idx == model.definiteIndex; - }) - if (msg == nil) { - asrList.append((text,model.definiteIndex)) - } else { - asrList[msg!] = (text,model.definiteIndex) - } - asrText = asrList.compactMap({ (str,idx) in - return str - }).joined(separator: "\n") - asrCallback?(asrText) + if model.channel == 1 { + //左耳 + let msg = asrList.firstIndex (where: { (str,idx) in + return idx == model.definiteIndex; + }) + if (msg == nil) { + asrList.append((text,model.definiteIndex)) + } else { + asrList[msg!] = (text,model.definiteIndex) + } + asrText = asrList.compactMap({ (str,idx) in + return str + }).joined(separator: "\n") + + asrCallback?(asrText) + } + else if model.channel == 2{ + //右耳 + let msg = asrOtherList.firstIndex (where: { (str,idx) in + return idx == model.definiteIndex; + }) + if (msg == nil) { + asrOtherList.append((text,model.definiteIndex)) + } else { + asrOtherList[msg!] = (text,model.definiteIndex) + } + asrOtherText = asrOtherList.compactMap({ (str,idx) in + return str + }).joined(separator: "\n") + + asrCallback?(asrOtherText) + } + } } stateChange: { [weak self] code in DCLogger.debug("状态改变",code) @@ -75,20 +101,34 @@ public class DCCallRecord { DCLogger.debug("文件录音保存路径 \(filePath ?? "")") self?.filePathCallBack?(filePath) } + + //通话录音声道数。1:单声道 ;2:⽴体声;默认单声道 + StarburstConfig.shared().callRecordChannel = 2 + //收到sdk传过来的opus音频数据,传到OpusManager解码。解码过程是异步 + StarburstSdk.shared().outputOpusData {[weak self] (config, opusData) in + DispatchQueue.global().async { + self?.opusCallBack?(opusData!) + } + } + } + + public func inputPcm(data:Data){ + StarburstSdk.shared().inputPcmData(data) } /// 0x00实时录音,0x0c通话录音 - public func start(type:Int,recordPath:String?){ + public func start(){ asrList = [] asrText = "" - - filePath = recordPath - DCLogger.debug("设置地址 \(filePath ?? "")") + + + asrOtherList = [] + asrOtherText = "" setupRecord() let config = StarburstBleAsrConfig() - config.type = type + config.type = 0x0c StarburstSdk.shared().startDeviceRecord(config) } diff --git a/DeepChordsSdk_iOS/DeepChordsSdk/Example/DeepChordsSdk/DCDevice.swift b/DeepChordsSdk_iOS/DeepChordsSdk/Example/DeepChordsSdk/DCDevice.swift index 40006b7..9b557ed 100644 --- a/DeepChordsSdk_iOS/DeepChordsSdk/Example/DeepChordsSdk/DCDevice.swift +++ b/DeepChordsSdk_iOS/DeepChordsSdk/Example/DeepChordsSdk/DCDevice.swift @@ -201,13 +201,15 @@ public class DCDevice{ var cmd: UInt8 = 0x0C var data:UInt8 = 0x06 var index:UInt8 = UInt8(index) - var value:UInt8 = UInt8(value) + let int8Value: Int8 = Int8(value) + let valueData = withUnsafeBytes(of: int8Value) { Data($0) } + var total = Data() total.append(&head, count: 1) total.append(&cmd, count: 1) total.append(&data, count: 1) total.append(&index, count: 1) - total.append(&value, count: 1) + total.append(valueData) total.addCrc() let sender = BleSender() @@ -243,9 +245,19 @@ public class DCDevice{ let type = UInt8(result.data[2].int) DCLogger.debug(type) if type == 5 { + let data = result.data[3...12] + let int8Array = data.map { byte in + return Data([byte]).toInt8() + } + print(int8Array) + let list = int8Array.map{Int($0)} + finished((type,list),true) + + } + else{ + finished((type,[]),true) } - finished((type,[]),true) } else{ finished(nil,false) @@ -254,7 +266,15 @@ public class DCDevice{ DCBleManager.shared.send(sender) } } - +extension Data { + func toInt8() -> Int8 { + var int8Result: Int8 = 0 + self.withUnsafeBytes { + int8Result = $0.load(as: Int8.self) + } + return int8Result + } +} extension DCDevice{ //0x01(打开AI对话) diff --git a/DeepChordsSdk_iOS/DeepChordsSdk/Example/DeepChordsSdk/DeepChordsAiSdk.swift b/DeepChordsSdk_iOS/DeepChordsSdk/Example/DeepChordsSdk/DeepChordsAiSdk.swift index f11c184..f11632f 100644 --- a/DeepChordsSdk_iOS/DeepChordsSdk/Example/DeepChordsSdk/DeepChordsAiSdk.swift +++ b/DeepChordsSdk_iOS/DeepChordsSdk/Example/DeepChordsSdk/DeepChordsAiSdk.swift @@ -18,7 +18,7 @@ public class DeepChordsAiSdk{ StarburstConfig.shared().switch(to: .ble) StarburstConfig.shared().appId = "prjzVnOEpKL1N" - StarburstConfig.shared().isDebug = false + StarburstConfig.shared().isDebug = true //MARK: 配置缓存路径 StarburstConfig.shared().sdkFolder = NSTemporaryDirectory() // StarburstConfig.shared().sdkFolder = NSHomeDirectory() + "/Documents/DeepChordsSdk" @@ -30,8 +30,6 @@ public class DeepChordsAiSdk{ StarburstConfig.shared().enableEarbudsSwitchSync = true //耳机仓表情下发开关 StarburstConfig.shared().enableEmotionSyncToDevice = false - // 通话录音声道数。1:单声道 ;2:⽴体声;默认单声道 - StarburstConfig.shared().callRecordChannel = 2 //添加调试信息 // StarburstConfig.shared().debugInfo = [ // "x-use-ppe":"1", diff --git a/ShenYin/ShenYin/Sdk/CCDevice.swift b/ShenYin/ShenYin/Sdk/CCDevice.swift index 43af2ba..16cefe8 100644 --- a/ShenYin/ShenYin/Sdk/CCDevice.swift +++ b/ShenYin/ShenYin/Sdk/CCDevice.swift @@ -214,8 +214,8 @@ extension CCDevice{ } } else{ -// DCDevice.shared.setCustomEQ(index: UInt8(index), value: value) {result in -// } + DCDevice.shared.setCustomEQ(index: UInt8(index), value: value) {result in + } } } } diff --git a/ShenYin/ShenYin/Sdk/CCPage.swift b/ShenYin/ShenYin/Sdk/CCPage.swift index 1fecf7b..a53d0ef 100644 --- a/ShenYin/ShenYin/Sdk/CCPage.swift +++ b/ShenYin/ShenYin/Sdk/CCPage.swift @@ -33,10 +33,10 @@ class CCPage{ } else{ // if JoySdkManager.shared.callRecord.supportStereo{ -// App.shared.goToPage(DcStereoCallVC()) + App.shared.goToPage(DcStereoCallVC()) // } // else{ - App.shared.goToPage(DcCallingRecordVC()) +// App.shared.goToPage(DcCallingRecordVC()) // } } } diff --git a/ShenYin/ShenYin/Sdk/DcSdk/DcStereo.swift b/ShenYin/ShenYin/Sdk/DcSdk/DcStereo.swift new file mode 100644 index 0000000..cdef7de --- /dev/null +++ b/ShenYin/ShenYin/Sdk/DcSdk/DcStereo.swift @@ -0,0 +1,83 @@ +// +// DcStereo.swift +// ShenYin +// +// Created by liangshi on 2025/12/31. +// + +import UIKit +import DeepChordsSdk + +class DcStereo:NSObject{ + static let shared = DcStereo() + + var recordFinish:((String)->Void)? + var stereoNeedReloadData:((String,Int)->Void)? + var selfText = "" + + var otherText = "" + /// 状态码回调 + public var codeCallback:((Int)->Void)? + public var callRecordNotOnCall:(()->Void)? + + + override init() { + super.init() + setupSdk() + } + func setupSdk(){ + DCCallRecord.shared.asrCallback = { [weak self] text in + guard let self = self else{return} + selfText = text + stereoNeedReloadData?(text,1) + } + DCCallRecord.shared.asrOtherCallback = { [weak self] text in + guard let self = self else{return} + otherText = text + stereoNeedReloadData?(text,2) + } + DCCallRecord.shared.codeCallback = { [weak self] code in + guard let self = self else{return} + codeCallback?(code) + } + DCCallRecord.shared.opusCallBack = { data in + OpusManager.shared().write(data) + } + DCCallRecord.shared.filePathCallBack = { [weak self] path in + guard let self = self else{return} + if selfText.isEmpty || otherText.isEmpty { + return + } + guard let path = path,path.isNotEmpty else{ + return + } + let path1 = OpusTool.opusFile(toWAVFile: path) + guard let wavPath = DCFolder.recordFileResave(srcPath: path1) else{return} + recordFinish?(wavPath) + } + + //设置解码参数 + OpusManager.shared().setupSampleRate(16000, frameRate: 80) + //opus转成pcm,发送给sdk + OpusManager.shared().pcmDataCallback = { data in + DCCallRecord.shared.inputPcm(data: data) + } + } + func setRecordLanage(_ language:CCAiLanguage){ + DCBleRecord.shared.fromLanguage = language.value + } + func recordStart(){ + selfText = "" + otherText = "" + setupSdk() + if !CCCall.shared.isInCall { + callRecordNotOnCall?() + return + } + Logger.debug("开启通话录音") + DCCallRecord.shared.start() + } + func recordStop(){ + DCBleRecord.shared.stop() + } +} diff --git a/ShenYin/ShenYin/Sdk/DcSdk/DcThly.swift b/ShenYin/ShenYin/Sdk/DcSdk/DcThly.swift index 09c479c..b4181d7 100644 --- a/ShenYin/ShenYin/Sdk/DcSdk/DcThly.swift +++ b/ShenYin/ShenYin/Sdk/DcSdk/DcThly.swift @@ -61,12 +61,6 @@ class DcThly:NSObject{ Logger.debug("开启通话录音") DCBleRecord.shared.start(type: 0x00, recordPath: nil ) } - func recordResume(){ - // JoyGemRecordManager.shared().resume() - } - func recordPause(){ - // JoyGemRecordManager.shared().pause() - } func recordStop(){ DCBleRecord.shared.stop() } diff --git a/ShenYin/ShenYin/Sdk/DcSdk/DcXcly.swift b/ShenYin/ShenYin/Sdk/DcSdk/DcXcly.swift index b138c0d..75a42dc 100644 --- a/ShenYin/ShenYin/Sdk/DcSdk/DcXcly.swift +++ b/ShenYin/ShenYin/Sdk/DcSdk/DcXcly.swift @@ -63,12 +63,12 @@ class DcXcly:NSObject{ wavPath = nil setupSdk() recordPath = DcXcly.getFilePath() - DCBleRecord.shared.start(type: 0x0c, recordPath: recordPath ) + DCBleRecord.shared.start(type: 0x00, recordPath: recordPath ) } func recordResume(){ wavPath = nil pausText = recordText - DCBleRecord.shared.start(type: 0x0c, recordPath: recordPath ) + DCBleRecord.shared.start(type: 0x00, recordPath: recordPath ) } func recordPause(){ DCBleRecord.shared.stop() @@ -94,4 +94,12 @@ extension DcXcly{ let path = cacheDirectory.appendingPathComponent(name).path return path } +// static func getFilePath()->String?{ +// // 获取缓存目录路径 +// let cacheDirectory = DCFolder.record +// // 构建压缩文件路径 +// let name = "\(Int(Date().timeIntervalSince1970*1000)).opus" +// let path = cacheDirectory + name +// return path +// } } diff --git a/ShenYin/ShenYin/Sdk/DcSdk/VC/DcChatVC.swift b/ShenYin/ShenYin/Sdk/DcSdk/VC/DcChatVC.swift index 5b4b3f2..9de5665 100644 --- a/ShenYin/ShenYin/Sdk/DcSdk/VC/DcChatVC.swift +++ b/ShenYin/ShenYin/Sdk/DcSdk/VC/DcChatVC.swift @@ -166,7 +166,6 @@ class DcChatVC:BaseVC{ extension DcChatVC:ChatRecordBarDelegate{ func recordBarCancel(_ toolBar: ChatRecordBar) { -// JoyGemChatManager.shared().stopSingleChat() DcChatManager.shared.stopChat() if let item = DcChatManager.shared.dataList.last,item.content.isEmpty{ DcChatManager.shared.dataList.removeLast() @@ -175,12 +174,10 @@ extension DcChatVC:ChatRecordBarDelegate{ } func recordBarStart(_ toolBar: ChatRecordBar) { -// JoyGemChatManager.shared().startSingleChat() DcChatManager.shared.startChat() } func recordBarStop(_ toolBar: ChatRecordBar) { -// JoyGemChatManager.shared().stopSingleChat() DcChatManager.shared.stopChat() } } diff --git a/ShenYin/ShenYin/Sdk/DcSdk/VC/DcChinese2EnglishVC.swift b/ShenYin/ShenYin/Sdk/DcSdk/VC/DcChinese2EnglishVC.swift index 0406d2f..bd19b94 100644 --- a/ShenYin/ShenYin/Sdk/DcSdk/VC/DcChinese2EnglishVC.swift +++ b/ShenYin/ShenYin/Sdk/DcSdk/VC/DcChinese2EnglishVC.swift @@ -84,18 +84,20 @@ class DcChinese2EnglishVC:BaseVC{ CCAiManager.preparePlayBlueTooth() } override func navleftViewTapped() { - if toolBar.recordBtn.isSelected { - self.sdk.stop() - // CustomAlert.showWith(title: "提示".l10n, messgage: "当前正在录音,确定放弃当前录音吗".l10n, cancelCallback: {}) { - // self.sdk.stop() - //// PcmSound.sharedInstance().stopAudioUnit() - //// PcmSound.sharedInstance().cleanup() - // super.navleftViewTapped() - // } - } - else{ - super.navleftViewTapped() - } + self.sdk.stop() + super.navleftViewTapped() +// if toolBar.recordBtn.isSelected { +// self.sdk.stop() +// // CustomAlert.showWith(title: "提示".l10n, messgage: "当前正在录音,确定放弃当前录音吗".l10n, cancelCallback: {}) { +// // self.sdk.stop() +// //// PcmSound.sharedInstance().stopAudioUnit() +// //// PcmSound.sharedInstance().cleanup() +// // super.navleftViewTapped() +// // } +// } +// else{ +// super.navleftViewTapped() +// } } override func navRightViewTapped() { let tip = RecordTipsView(type: .chinese2english) diff --git a/ShenYin/ShenYin/Sdk/DcSdk/VC/DcDialogTranslateVC.swift b/ShenYin/ShenYin/Sdk/DcSdk/VC/DcDialogTranslateVC.swift index bec6320..955d64b 100644 --- a/ShenYin/ShenYin/Sdk/DcSdk/VC/DcDialogTranslateVC.swift +++ b/ShenYin/ShenYin/Sdk/DcSdk/VC/DcDialogTranslateVC.swift @@ -332,157 +332,6 @@ extension DcDialogTranslateVC:DialogRecordBarDelegate{ DCBleRecord.shared.stop() } } - -//extension DcDialogTranslateVC : JoyGemSIManagerDelegate { -// -// -// func siManagerStopped(_ manager: JoyGemSIManager, reason code: JoyGemRecordStopCode) { -// if let model = dataList.last,model.send.isEmpty{ -// dataList.removeLast() -// refreshData() -// } -// } -// -// func siManager(_ manager: JoyGemSIManager, didUpdateRaw model: JoyGemAsrModel) { -// let msg = tmpList.firstIndex (where: { (str,idx) in -// return idx == model.index; -// }) -// if (msg == nil) { -// tmpList.append((model.text,model.index)) -// } else { -// tmpList[msg!] = (model.text,model.index) -// } -// -// ///监听到一句话结束,自动结束当前录音 -// if (model.definite == true) { -// toolBar.stopRecord(.phone) -// stopPhoneRecord() -// } -// -// guard let model = dataList.last else { -// return -// } -// -// model.send = tmpList.compactMap({ (str,idx) in -// return str -// }).joined(separator: "\n") -// refreshData() -// } -// -// func siManager(_ manager: JoyGemSIManager, didUpdateTranslate model: JoyGemAsrModel) { -// let msg = tmpOtherList.firstIndex (where: { (str,idx) in -// return idx == model.index; -// }) -// if (msg == nil) { -// tmpOtherList.append((model.text,model.index)) -// } else { -// tmpOtherList[msg!] = (model.text,model.index) -// } -// -// guard let model = dataList.last else { -// return -// } -// -// model.response = tmpOtherList.compactMap({ (str,idx) in -// return str -// }).joined(separator: "\n") -// refreshData() -// } -// -// func siManager(_ manager: JoyGemSIManager, saveFile path: String) { -// -// } -// -// -// func siManager(_ manager: JoyGemSIManager, stateChange code: JoyGemStateCode) { -// -// } -// -// func siManagerStopped(_ manager: JoyGemSIManager) { -// -// } -// func siManager(_ manager: JoyGemSIManager, didUpdateAudioData data: Data, sampleRate: UInt) { -// PcmSound.sharedInstance().feed(data) -// } -// func siManager(_ manager: JoyGemSIManager, onError code: JoyGemErrorCode) { -// -// } -//} - -//extension DcDialogTranslateVC : JoyGemSIDeviceManagerDelegate { -// func siDeviceManagerStopped(_ manager: JoyGemSIDeviceManager, reason code: JoyGemRecordStopCode) { -// if let model = dataList.last,model.send.isEmpty{ -// dataList.removeLast() -// refreshData() -// } -// } -// -// func siDeviceManager(_ manager: JoyGemSIDeviceManager, didUpdateRaw model: JoyGemAsrModel) { -// Logger.debug("text: \(model.text),index: \(model.index)") -// let msg = tmpList.firstIndex (where: { (str,idx) in -// return idx == model.index; -// }) -// if (msg == nil) { -// tmpList.append((model.text,model.index)) -// } else { -// tmpList[msg!] = (model.text,model.index) -// } -// -// ///监听到一句话结束,自动结束当前录音 -// if (model.definite == true) { -// toolBar.stopRecord(.earphone) -// stopEarRecord() -// } -// -// guard let model = dataList.last else { -// return -// } -// -// model.send = tmpList.compactMap({ (str,idx) in -// return str -// }).joined(separator: "\n") -// refreshData() -// } -// -// func siDeviceManager(_ manager: JoyGemSIDeviceManager, didUpdateTranslate model: JoyGemAsrModel) { -// let msg = tmpOtherList.firstIndex (where: { (str,idx) in -// return idx == model.index; -// }) -// if (msg == nil) { -// tmpOtherList.append((model.text,model.index)) -// } else { -// tmpOtherList[msg!] = (model.text,model.index) -// } -// -// guard let model = dataList.last else { -// return -// } -// -// model.response = tmpOtherList.compactMap({ (str,idx) in -// return str -// }).joined(separator: "\n") -// refreshData() -// } -// func siDeviceManager(_ manager: JoyGemSIDeviceManager, didUpdateAudioData data: Data, sampleRate: UInt) { -// PcmSound.sharedInstance().feed(data) -// } -// func siDeviceManager(_ manager: JoyGemSIDeviceManager, update mode: JoyGemRecordMode) { -// -// } -// -// func siDeviceManager(_ manager: JoyGemSIDeviceManager, saveFile path: String) { -// Logger.debug("path: \(path)") -// } -// -// func siDeviceManager(_ manager: JoyGemSIDeviceManager, stateChange code: JoyGemStateCode) { -// Logger.debug("code: \(code)") -// } -// -// func siDeviceManager(_ manager: JoyGemSIDeviceManager, onError code: JoyGemErrorCode) { -// -// } -//} - extension DcDialogTranslateVC : PcmSoundDelegate { func remaining(_ frames: UInt) { Logger.debug("[frame:\(frames)]"); diff --git a/ShenYin/ShenYin/Sdk/DcSdk/VC/DcStereoCallVC.swift b/ShenYin/ShenYin/Sdk/DcSdk/VC/DcStereoCallVC.swift index e672677..847370f 100644 --- a/ShenYin/ShenYin/Sdk/DcSdk/VC/DcStereoCallVC.swift +++ b/ShenYin/ShenYin/Sdk/DcSdk/VC/DcStereoCallVC.swift @@ -121,51 +121,51 @@ class DcStereoCallVC:BaseVC{ } override func setupData() { if bgEnter { - selfTextView.text = JoySdkManager.shared.callRecord.selfText - otherTextView.text = JoySdkManager.shared.callRecord.otherText + selfTextView.text = DcStereo.shared.selfText + otherTextView.text = DcStereo.shared.otherText } } func setupSdk(){ -// JoySdkManager.shared.callRecord.recordFinish = {[weak self] path in -// guard let self = self else { return } -// if !needSave { -// return -// } -// let v = PopTextField() -// v.show() -// v.cancelTap = { -// App.shared.popPage() -// } -// v.okTap = { [weak self] text in -// guard let self = self else{return} -// gotoDetail(fileName: text, wavPath: path, language: toolBar.leftItem.language) -// } -// } -// JoySdkManager.shared.callRecord.stereoNeedReloadData = {[weak self] (text,index) in -// guard let self = self else { return } -// if (index == 1) { -// selfTextView.text = text -// selfTextView.scrollToBottom() -// } else if (index == 2) { -// otherTextView.text = text -// otherTextView.scrollToBottom() -// } -// } -// JoySdkManager.shared.callRecord.callRecordAutoFinish = {[weak self] in + DcStereo.shared.recordFinish = {[weak self] path in + guard let self = self else { return } + if !needSave { + return + } + let v = PopTextField() + v.show() + v.cancelTap = { + App.shared.popPage() + } + v.okTap = { [weak self] text in + guard let self = self else{return} + gotoDetail(fileName: text, wavPath: path, language: toolBar.leftItem.language) + } + } + DcStereo.shared.stereoNeedReloadData = {[weak self] (text,index) in + guard let self = self else { return } + if (index == 1) { + selfTextView.text = text + selfTextView.scrollToBottom() + } else if (index == 2) { + otherTextView.text = text + otherTextView.scrollToBottom() + } + } +// DcStereo.shared.callRecordAutoFinish = {[weak self] in // guard let self = self else { return } // stopAction() // } -// JoySdkManager.shared.callRecord.callRecordNotOnCall = {[weak self] in -// guard let self = self else { return } -// YLprogressHUD.showAutoHiden("未处于通话状态".l10n) -// rhythView.reset() -// toolBar.recordBtn.isSelected = false -// toolBar.leftItem.alpha = 1 -// } -// if autoStart{ -// startRecord() -// } + DcStereo.shared.callRecordNotOnCall = {[weak self] in + guard let self = self else { return } + YLprogressHUD.showAutoHiden("未处于通话状态".l10n) + rhythView.reset() + toolBar.recordBtn.isSelected = false + toolBar.leftItem.alpha = 1 + } + if autoStart{ + startRecord() + } } override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) @@ -180,7 +180,7 @@ class DcStereoCallVC:BaseVC{ CustomAlert.showWith(title: "提示".l10n, messgage: "当前正在录音,确定放弃当前录音吗?".l10n, cancelCallback: {}) {[unowned self] in self.rhythView.stopTimer() self.needSave = false - JoySdkManager.shared.callRecord.callRecordStop() + DcStereo.shared.recordStop() self.navigationController?.popViewController(animated: true) } } @@ -198,18 +198,16 @@ class DcStereoCallVC:BaseVC{ extension DcStereoCallVC:FieldRecordBarDelegate{ func fieldRecordBar(_ bar: FieldRecordBar, languageChange language: CCAiLanguage) { - JoySdkManager.shared.callRecord.setCallRecoordLanage(language) + DcStereo.shared.setRecordLanage(language) AiLanguageCache.save(type: .thly, lan: language) } func fieldRecordBar(_ bar: FieldRecordBar, stateChange state: RecordSate) { if state == .start { - // selfMessageList.removeAll() - // otherMessageList.removeAll() selfTextView.text = nil otherTextView.text = nil - JoySdkManager.shared.callRecord.callRecordStart() rhythView.startTimer() + DcStereo.shared.recordStart() } else if state == .stop{ stopAction() @@ -217,7 +215,7 @@ extension DcStereoCallVC:FieldRecordBarDelegate{ } func stopAction(){ rhythView.stopTimer() - JoySdkManager.shared.callRecord.callRecordStop() + DcStereo.shared.recordStop() toolBar.startAnimating() } func gotoDetail( fileName:String,wavPath:String,language:CCAiLanguage){ diff --git a/ShenYin/ShenYin/Sdk/JoySdk/VC/JoyChinese2EnglishVC.swift b/ShenYin/ShenYin/Sdk/JoySdk/VC/JoyChinese2EnglishVC.swift index 0fcfc68..361c5a8 100644 --- a/ShenYin/ShenYin/Sdk/JoySdk/VC/JoyChinese2EnglishVC.swift +++ b/ShenYin/ShenYin/Sdk/JoySdk/VC/JoyChinese2EnglishVC.swift @@ -84,18 +84,20 @@ class JoyChinese2EnglishVC:BaseVC{ CCAiManager.preparePlayBlueTooth() } override func navleftViewTapped() { - if toolBar.recordBtn.isSelected { - self.sdk.stop() -// CustomAlert.showWith(title: "提示".l10n, messgage: "当前正在录音,确定放弃当前录音吗".l10n, cancelCallback: {}) { -// self.sdk.stop() -//// PcmSound.sharedInstance().stopAudioUnit() -//// PcmSound.sharedInstance().cleanup() -// super.navleftViewTapped() -// } - } - else{ - super.navleftViewTapped() - } + self.sdk.stop() + super.navleftViewTapped() +// if toolBar.recordBtn.isSelected { +// self.sdk.stop() +//// CustomAlert.showWith(title: "提示".l10n, messgage: "当前正在录音,确定放弃当前录音吗".l10n, cancelCallback: {}) { +//// self.sdk.stop() +////// PcmSound.sharedInstance().stopAudioUnit() +////// PcmSound.sharedInstance().cleanup() +//// super.navleftViewTapped() +//// } +// } +// else{ +// super.navleftViewTapped() +// } } override func navRightViewTapped() { let tip = RecordTipsView(type: .chinese2english) diff --git a/ShenYin/ShenYin/ShenYin-Bridging-Header.h b/ShenYin/ShenYin/ShenYin-Bridging-Header.h index 1e273c7..b1041af 100644 --- a/ShenYin/ShenYin/ShenYin-Bridging-Header.h +++ b/ShenYin/ShenYin/ShenYin-Bridging-Header.h @@ -11,3 +11,4 @@ #import #import "JLBleAssistManager.h" #import "OpusTool.h" +#import "OpusManager.h" diff --git a/ShenYin/ShenYin/UI/Home/Chat/RoleListVC.swift b/ShenYin/ShenYin/UI/Home/Chat/RoleListVC.swift index 38600de..4671ecd 100644 --- a/ShenYin/ShenYin/UI/Home/Chat/RoleListVC.swift +++ b/ShenYin/ShenYin/UI/Home/Chat/RoleListVC.swift @@ -42,11 +42,7 @@ class RoleListVC: BaseVC{ } } override func setupData() { -// JoyGemChatManager.shared().getSpeakerList {[weak self] speakers in -// guard let self = self else{return} -// self.list = speakers -// self.tableView.reloadData() -// } + } }