| 
														
															@@ -34,7 +34,7 @@ public class BFRecordScreenController: BFBaseViewController { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     public var recordEndHandle: ((_ currentRecord: PQVoiceModel?) -> Void)? 
														 | 
														
														 | 
														
															     public var recordEndHandle: ((_ currentRecord: PQVoiceModel?) -> Void)? 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     // 字幕按钮点击上报 
														 | 
														
														 | 
														
															     // 字幕按钮点击上报 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     public var subTitleBtnClickHandle: ((_ isOn: Bool) -> Void)? 
														 | 
														
														 | 
														
															     public var subTitleBtnClickHandle: ((_ isOn: Bool) -> Void)? 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    public var currentRecordId: String? // 当前录制Id 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//    public var currentRecordId: String? // 当前录制Id 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     // MARK: - 录制参数 
														 | 
														
														 | 
														
															     // MARK: - 录制参数 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -486,34 +486,34 @@ public class BFRecordScreenController: BFBaseViewController { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															         // 录音字幕回调 
														 | 
														
														 | 
														
															         // 录音字幕回调 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         recorderManager?.subtitleRecordHandle = { [weak self] eventCode, recordId, asrResult, audioFilePath, _ in 
														 | 
														
														 | 
														
															         recorderManager?.subtitleRecordHandle = { [weak self] eventCode, recordId, asrResult, audioFilePath, _ in 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            if asrResult == nil || (asrResult?.count ?? 0) <= 0 { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                BFLog(message: "识别结果为空????不能生成字幕数据") 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                return 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            if eventCode == 26 { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                self?.currentRecordId = nil 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            if eventCode == 0 { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                self?.currentRecordId = recordId 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            // 只有为24时才有字幕返回 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            if eventCode != 24 || recordId == nil{ 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                return 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            BFLog(1, message: "eventcode:\(eventCode), recordid:\(recordId), asr:\(asrResult)") 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+             
														 | 
													
												
											
												
													
														| 
														 | 
														
															             DispatchQueue.global().async { [weak self] in 
														 | 
														
														 | 
														
															             DispatchQueue.global().async { [weak self] in 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                let newSubtitle = PQEditSubTitleModel() 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                newSubtitle.recordId = recordId 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                    if eventCode == 26 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                        self?.currentRecordId = nil 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                    } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                    if eventCode == 0 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                        self?.currentRecordId = recordId 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                    } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                if asrResult == nil || (asrResult?.count ?? 0) <= 0 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    BFLog(1, message: "onNuiEventCallback 识别结果为空????不能生成字幕数据") 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    return 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                // 只有为24时才有字幕返回 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                if eventCode != 24 || recordId == nil{ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    BFLog(1, message: "onNuiEventCallback eventCode != 24 || recordId == nil") 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    return 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 let dicResult: [String: Any]? = jsonStringToDictionary(asrResult!) 
														 | 
														
														 | 
														
															                 let dicResult: [String: Any]? = jsonStringToDictionary(asrResult!) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 let header = dicResult?["header"] as? [String: Any] 
														 | 
														
														 | 
														
															                 let header = dicResult?["header"] as? [String: Any] 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 let payload = dicResult?["payload"] as? [String: Any] 
														 | 
														
														 | 
														
															                 let payload = dicResult?["payload"] as? [String: Any] 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 BFLog(1, message: "onNuiEventCallback event 识别结果:) \(payload?["result"] ?? "") ,taskId:\((header?["task_id"] as? String) ?? "taskId"), 识别时间:\(((payload?["begin_time"]) as? Int) ?? 0) ~ \(((payload?["time"]) as? Int) ?? 0) startTime:\(self?.recorderManager?.voiceModel?.startCMTime.seconds ?? 0.0)") 
														 | 
														
														 | 
														
															                 BFLog(1, message: "onNuiEventCallback event 识别结果:) \(payload?["result"] ?? "") ,taskId:\((header?["task_id"] as? String) ?? "taskId"), 识别时间:\(((payload?["begin_time"]) as? Int) ?? 0) ~ \(((payload?["time"]) as? Int) ?? 0) startTime:\(self?.recorderManager?.voiceModel?.startCMTime.seconds ?? 0.0)") 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 // 1,保存字幕数据 begin_time是开始出现文字的时间,time 是结束文字出现的时间 单位都为毫秒,都是相对于录制音频数据整段时间。self.recorderManager.voiceModel?.startCMTime.seconds 为开始的录制的时间,开始和结束都要加上这个时差 
														 | 
														
														 | 
														
															                 // 1,保存字幕数据 begin_time是开始出现文字的时间,time 是结束文字出现的时间 单位都为毫秒,都是相对于录制音频数据整段时间。self.recorderManager.voiceModel?.startCMTime.seconds 为开始的录制的时间,开始和结束都要加上这个时差 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                let newSubtitle = PQEditSubTitleModel() 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                // 任务全局唯一ID,请记录该值,便于排查问题。 每次 startRecorder 和 stopRecoder 之间  task_Id都不会变化 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                let taskID = header?["task_id"] as? String 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                newSubtitle.taskID = taskID ?? "" 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                newSubtitle.recordId = self?.currentRecordId 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                BFLog(1, message: "对应关系:字幕所属地址:taskID:\(taskID ?? ""),\((audioFilePath ?? "b").replacingOccurrences(of: documensDirectory, with: "")), 开始录音输入:\((self?.recorderManager?.voiceModel?.wavFilePath ?? "aa").replacingOccurrences(of: documensDirectory, with: ""))") 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                let taskID = "aa" 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 // 这里加300ms 是因为返回结果为了切到字,时长提前一些时间,具体时间官方没说和原音频有关系。这里我们先延后300ms 单位:毫秒。 
														 | 
														
														 | 
														
															                 // 这里加300ms 是因为返回结果为了切到字,时长提前一些时间,具体时间官方没说和原音频有关系。这里我们先延后300ms 单位:毫秒。 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 var tempVoice: PQVoiceModel? 
														 | 
														
														 | 
														
															                 var tempVoice: PQVoiceModel? 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 var tempItem: BFRecordItemModel? 
														 | 
														
														 | 
														
															                 var tempItem: BFRecordItemModel? 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -794,7 +794,7 @@ public class BFRecordScreenController: BFBaseViewController { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         for (index, subtitle) in itemModels[currItemModelIndex].titleStickers.enumerated() { 
														 | 
														
														 | 
														
															         for (index, subtitle) in itemModels[currItemModelIndex].titleStickers.enumerated() { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             if CMTimeCompare(subtitle.timelineIn, time) <= 0, CMTimeCompare(subtitle.timelineOut, time) > 0, subtitle.audioFilePath.count > 0 { //  audioFilePath.count 这个条件是确保这个字幕有对应录音 
														 | 
														
														 | 
														
															             if CMTimeCompare(subtitle.timelineIn, time) <= 0, CMTimeCompare(subtitle.timelineOut, time) > 0, subtitle.audioFilePath.count > 0 { //  audioFilePath.count 这个条件是确保这个字幕有对应录音 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 findShowSubtitle = subtitle 
														 | 
														
														 | 
														
															                 findShowSubtitle = subtitle 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                BFLog(1, message: "找到要显示的字幕 in \((findShowSubtitle?.timelineIn ?? .zero).seconds) out \((findShowSubtitle?.timelineOut ?? .zero).seconds) text:\(findShowSubtitle?.text ?? "") currTime is \(CMTimeGetSeconds(time))") 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//                BFLog(1, message: "找到要显示的字幕 in \((findShowSubtitle?.timelineIn ?? .zero).seconds) out \((findShowSubtitle?.timelineOut ?? .zero).seconds) text:\(findShowSubtitle?.text ?? "") currTime is \(CMTimeGetSeconds(time))") 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 showSubtitleIndex = index 
														 | 
														
														 | 
														
															                 showSubtitleIndex = index 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 break 
														 | 
														
														 | 
														
															                 break 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             } 
														 | 
														
														 | 
														
															             } 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -1091,7 +1091,7 @@ public class BFRecordScreenController: BFBaseViewController { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         let model = PQVoiceModel() 
														 | 
														
														 | 
														
															         let model = PQVoiceModel() 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         model.startCMTime = currentAssetProgress 
														 | 
														
														 | 
														
															         model.startCMTime = currentAssetProgress 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         model.currIndex = currItemModelIndex 
														 | 
														
														 | 
														
															         model.currIndex = currItemModelIndex 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        model.recordId = getUniqueId(desc: "recordId") 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//        model.recordId = getUniqueId(desc: "recordId") 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         model.volume = 100 
														 | 
														
														 | 
														
															         model.volume = 100 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         recorderManager?.voiceModel = model 
														 | 
														
														 | 
														
															         recorderManager?.voiceModel = model 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         BFLog(3, message: "开始录制-开始:currentAssetProgress=\(currentAssetProgress.seconds),cuInde=\(currItemModelIndex),\(model)") 
														 | 
														
														 | 
														
															         BFLog(3, message: "开始录制-开始:currentAssetProgress=\(currentAssetProgress.seconds),cuInde=\(currItemModelIndex),\(model)") 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -1534,7 +1534,7 @@ public class BFRecordScreenController: BFBaseViewController { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             BFLog(3, message: "未找到可播放录音") 
														 | 
														
														 | 
														
															             BFLog(3, message: "未找到可播放录音") 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             return 
														 | 
														
														 | 
														
															             return 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        BFLog(1, message: "当前时间:\(CMTimeGetSeconds(currentT)), 找到的音频:\(recordedAudio.startCMTime.seconds) ~ \(recordedAudio.endCMTime.seconds), \(recordedAudio.wavFilePath ?? "")") 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//        BFLog(1, message: "当前时间:\(CMTimeGetSeconds(currentT)), 找到的音频:\(recordedAudio.startCMTime.seconds) ~ \(recordedAudio.endCMTime.seconds), \(recordedAudio.wavFilePath ?? "")") 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															         // 创建播放器 
														 | 
														
														 | 
														
															         // 创建播放器 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         if recordPlayer == nil || (recordPlayer?.currentItem?.asset as? AVURLAsset)?.url.lastPathComponent != (recordedAudio.wavFilePath as NSString?)?.lastPathComponent { 
														 | 
														
														 | 
														
															         if recordPlayer == nil || (recordPlayer?.currentItem?.asset as? AVURLAsset)?.url.lastPathComponent != (recordedAudio.wavFilePath as NSString?)?.lastPathComponent { 
														 |