|
@@ -413,21 +413,24 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
}
|
|
|
|
|
|
//录音字幕回调
|
|
|
- self?.recorderManager?.subtitleRecordHandle = {[weak self] asrResult in
|
|
|
+ self?.recorderManager?.subtitleRecordHandle = {[weak self] asrResult ,audioFilePath in
|
|
|
if(asrResult == nil){
|
|
|
BFLog(message: "识别结果为空????不能生成字幕数据")
|
|
|
return
|
|
|
}
|
|
|
let dicResult: [String: Any]? = jsonStringToDictionary(asrResult!)
|
|
|
|
|
|
+ let header = dicResult?["header"] as? [String: Any]
|
|
|
let payload = dicResult?["payload"] as? [String: Any]
|
|
|
|
|
|
-
|
|
|
+
|
|
|
BFLog(message: "识别结果:) \((payload?["result"])!) startTime:\(self?.recorderManager?.voiceModel?.startTime ?? 0.0)")
|
|
|
DispatchQueue.main.async {
|
|
|
// 1,保存字幕数据 begin_time是开始出现文字的时间,time 是结束文字出现的时间 单位都为毫秒,都是相对于录制音频数据整段时间。self.recorderManager.voiceModel?.startTime 为开始的录制的时间,开始和结束都要加上这个时差
|
|
|
|
|
|
let newSubtitle = PQEditSubTitleModel()
|
|
|
+ //任务全局唯一ID,请记录该值,便于排查问题。 每次 startRecorder 和 stopRecoder 之间 task_Id都不会变化
|
|
|
+ newSubtitle.taskID = (header?["task_id"] as? String) ?? ""
|
|
|
|
|
|
//这里加300ms 是因为返回结果为了切到字,时长提前一些时间,具体时间官方没说和原音频有关系。这里我们先延后300ms 单位:毫秒。
|
|
|
newSubtitle.timelineIn = (self?.recorderManager?.voiceModel?.startTime ?? 0.0) + Float64((((payload?["begin_time"]) as? Int) ?? 0) + 300) / 1000.0
|
|
@@ -439,8 +442,9 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
showText += "..."
|
|
|
}
|
|
|
newSubtitle.text = showText
|
|
|
+ newSubtitle.audioFilePath = audioFilePath ?? ""
|
|
|
|
|
|
- BFLog(message: "添加字幕数据 timelineIn \(newSubtitle.timelineIn) timelineOut \(newSubtitle.timelineOut) text \(newSubtitle.text)")
|
|
|
+ BFLog(message: "添加字幕数据 timelineIn \(newSubtitle.timelineIn) timelineOut \(newSubtitle.timelineOut) text r\(newSubtitle.text) 音频路径为:\(audioFilePath ?? "")")
|
|
|
newSubtitle.setting = self?.subtitleSettingView.subtitle.setting ?? BFSubTitileSettingModel()
|
|
|
|
|
|
self?.itemModels[self?.currItemModelIndex ?? 0].titleStickers.append(newSubtitle)
|