|
@@ -490,15 +490,14 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
let header = dicResult?["header"] as? [String: Any]
|
|
|
let payload = dicResult?["payload"] as? [String: Any]
|
|
|
-
|
|
|
- BFLog(1, message: "识别结果:) \((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: "识别结果:) \((payload)!),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)")
|
|
|
DispatchQueue.main.async {
|
|
|
// 1,保存字幕数据 begin_time是开始出现文字的时间,time 是结束文字出现的时间 单位都为毫秒,都是相对于录制音频数据整段时间。self.recorderManager.voiceModel?.startCMTime.seconds 为开始的录制的时间,开始和结束都要加上这个时差
|
|
|
|
|
|
let newSubtitle = PQEditSubTitleModel()
|
|
|
// 任务全局唯一ID,请记录该值,便于排查问题。 每次 startRecorder 和 stopRecoder 之间 task_Id都不会变化
|
|
|
newSubtitle.taskID = (header?["task_id"] as? String) ?? ""
|
|
|
- BFLog(1, message: "url:\(URL(fileURLWithPath: audioFilePath ?? "b").deletingPathExtension().lastPathComponent), wavpath:\(URL(fileURLWithPath: self?.recorderManager?.voiceModel?.wavFilePath ?? "aa").deletingPathExtension().lastPathComponent)")
|
|
|
+ BFLog(1, message: "对应关系:字幕所属地址:\((audioFilePath ?? "b").replacingOccurrences(of: documensDirectory, with: "")), 开始录音输入:\((self?.recorderManager?.voiceModel?.wavFilePath ?? "aa").replacingOccurrences(of: documensDirectory, with: ""))")
|
|
|
// 这里加300ms 是因为返回结果为了切到字,时长提前一些时间,具体时间官方没说和原音频有关系。这里我们先延后300ms 单位:毫秒。
|
|
|
if let audioUrl = audioFilePath, URL(fileURLWithPath: audioUrl).deletingPathExtension().lastPathComponent.contains(URL(fileURLWithPath: self?.recorderManager?.voiceModel?.wavFilePath ?? "aa").deletingPathExtension().lastPathComponent) {
|
|
|
newSubtitle.timelineIn = (self?.recorderManager?.voiceModel?.startCMTime ?? .zero) + CMTime(seconds: Float64((((payload?["begin_time"]) as? Int) ?? 0) + 300) / 1000.0, preferredTimescale: 1000)
|
|
@@ -548,8 +547,9 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
recorderManager?.endRecordHandle = { [weak self, weak recorderManager] voideModel, _ in
|
|
|
if let sself = self, let model = voideModel, FileManager.default.fileExists(atPath: model.wavFilePath ?? "") {
|
|
|
// 加入到语音数组里
|
|
|
+
|
|
|
model.endCMTime = sself.currentAssetProgress
|
|
|
- BFLog(1, message: "录制结束当前录音文件:\(model.wavFilePath ?? "")-\(model.startCMTime.seconds)-\(model.endCMTime.seconds)-\(model.endCMTime.seconds - model.startCMTime.seconds)")
|
|
|
+ BFLog(1, message: "对应关系:录制结束文件地址:\((model.wavFilePath ?? "").replacingOccurrences(of: documensDirectory, with: "")) 开始录音前地址:\((self?.recorderManager?.voiceModel?.wavFilePath ?? "aa").replacingOccurrences(of: documensDirectory, with: ""))- \(model.startCMTime.seconds)-\(model.endCMTime.seconds)-\(model.endCMTime.seconds - model.startCMTime.seconds)")
|
|
|
/// 注:录音机回调的录音时长大于一秒,而业务逻辑计算的会小于一秒
|
|
|
if (model.endCMTime.seconds - model.startCMTime.seconds) < 1 {
|
|
|
// 取消录制
|
|
@@ -634,6 +634,8 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
sself.currentPlayRecordIndex = -3 // 刚录音完,不需要播放录音
|
|
|
BFLog(3, message: "重置播放index-\(#function) = \(sself.currentPlayRecordIndex)")
|
|
|
recorderManager?.voiceModel = nil
|
|
|
+ } else {
|
|
|
+ BFLog(2, message: "数据出错!!!!\(voideModel?.wavFilePath ?? "")")
|
|
|
}
|
|
|
}
|
|
|
recorderManager?.cancelRecordHandle = { [weak self] voiceModel in
|