Parcourir la source

去掉字幕 30个字限制

jsonwang il y a 3 ans
Parent
commit
7404c000a9

+ 8 - 13
BFRecordScreenKit/Classes/RecordScreen/Controller/BFRecordScreenController.swift

@@ -492,7 +492,7 @@ 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?["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)")
 
             DispatchQueue.main.async {
                 // 1,保存字幕数据 begin_time是开始出现文字的时间,time 是结束文字出现的时间 单位都为毫秒,都是相对于录制音频数据整段时间。self.recorderManager.voiceModel?.startCMTime.seconds 为开始的录制的时间,开始和结束都要加上这个时差
@@ -529,14 +529,9 @@ public class BFRecordScreenController: BFBaseViewController {
                         return
                     }
                 }
-                var showText = ((payload?["result"]) as? String) ?? ""
-                if showText.count > subtitleMaxlength {
-                    showText = showText.substring(to: subtitleMaxlength)
-                    showText += "..."
-                }
+                let showText = ((payload?["result"]) as? String) ?? ""
                 newSubtitle.text = showText
 //                newSubtitle.audioFilePath = audioFilePath ?? ""
-
                 BFLog(1, message: "添加字幕数据 timelineIn \(newSubtitle.timelineIn.seconds) timelineOut \(newSubtitle.timelineOut.seconds) text: \(newSubtitle.text) 音频路径为:\(audioFilePath ?? "bb") 传入的地址:\(self?.recorderManager?.voiceModel?.wavFilePath ?? "aa")")
 
                 newSubtitle.setting = self?.subtitleSettingView.subtitle.setting ?? BFSubTitileSettingModel()
@@ -696,10 +691,6 @@ public class BFRecordScreenController: BFBaseViewController {
         }
         // 编辑字幕完成
         subtitleEditView.editSubtitleDone = { [weak self] newtext, index in
-            // 1,刷新 UI
-            self?.subtitleLabel.text = newtext
-
-            self?.setSubtitleStyle(settingModel: (self?.subtitleSettingView.subtitle.setting)!)
 
             // 更新缓存数据
             if index < (self?.itemModels[self?.currItemModelIndex ?? 0].titleStickers.count ?? 0) {
@@ -712,6 +703,10 @@ public class BFRecordScreenController: BFBaseViewController {
                     self?.itemModels[self?.currItemModelIndex ?? 0].titleStickers[index].text = newtext
                 }
             }
+
+            self?.setSubtitleStyle(settingModel: (self?.subtitleSettingView.subtitle.setting)!)
+
+         
         }
 
         layoutsubview()
@@ -722,8 +717,8 @@ public class BFRecordScreenController: BFBaseViewController {
             cShowHUB(superView: view, msg: "网络不佳,字幕可能无法生成")
         }
 
-//        view.addSubview(neoNuiDebugLabel)
-//        view.addSubview(audioQueueRecoderLabel)
+        view.addSubview(neoNuiDebugLabel)
+        view.addSubview(audioQueueRecoderLabel)
     }
 
     @objc func editSubtitle() {

+ 2 - 3
BFRecordScreenKit/Classes/RecordScreen/View/BFSubtitleEditView.swift

@@ -14,7 +14,7 @@ typealias EditSubtitleDone = (_ text: String,_ index:Int) -> Void
 
 
 //字幕最大数限制
-public let subtitleMaxlength:Int = 30
+//public let subtitleMaxlength:Int = 0
 
 class BFSubtitleEditView: UIView {
     
@@ -25,7 +25,6 @@ class BFSubtitleEditView: UIView {
     /// 输入框
     lazy var textView: BFTextView = {
         let textView = BFTextView()
-        textView.maxTextLength = subtitleMaxlength
         textView.maxTextLengthRemind = ""
         textView.backgroundColor = UIColor.clear
         textView.textColor = UIColor.hexColor(hexadecimal: "#FFFFFF")
@@ -104,7 +103,7 @@ class BFSubtitleEditView: UIView {
 
     func setNewText(text: String,index:Int) {
         showSubtitleIndex = index
-        textView.text = text.substring(to: subtitleMaxlength)
+        textView.text = text
 //        BFLog(message: "传值\(textView.text)")
 //
 //        let attributedText = NSMutableAttributedString(string: textView.text,attributes: [.font: UIFont.systemFont(ofSize: CGFloat(settingModel.subtitleSize)  * 375 / 1080),.strokeWidth:-6,.strokeColor: settingModel.strokeColor,.foregroundColor:settingModel.fontColor])