|
@@ -0,0 +1,70 @@
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+import Foundation
|
|
|
+import BFFramework
|
|
|
+import ObjectMapper
|
|
|
+import RealmSwift
|
|
|
+import BFVideoEditKit
|
|
|
+public class BFRecordScreenViewModel:NSObject{
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ class public func batchUploadRecordVoiceMatarialData(beginTime: CMTime, locationPath: String, completeHander: @escaping (_ subTitleList: List<PQEditVisionTrackMaterialsModel>?, _ msg: String?) -> Void) {
|
|
|
+
|
|
|
+ BFLog(message: "录音文件开始上传--\(locationPath)")
|
|
|
+
|
|
|
+ if !FileManager.default.fileExists(atPath:documensDirectory + locationPath) {
|
|
|
+ BFLog(message: "上传录音-录音文件不存在")
|
|
|
+ } else {
|
|
|
+
|
|
|
+ let assert = AVURLAsset(url: URL(fileURLWithPath: documensDirectory + locationPath), options: nil)
|
|
|
+ let voiceMaterials: PQEditVisionTrackMaterialsModel = PQEditVisionTrackMaterialsModel()
|
|
|
+ voiceMaterials.locationPath = locationPath
|
|
|
+ voiceMaterials.type = "voice"
|
|
|
+ voiceMaterials.duration = assert.duration.seconds * 1_000_000
|
|
|
+ BFLog(message: "上传录音-开始上传录音")
|
|
|
+ PQVideoEditViewModel.uploadMatarialData(isBatchUpload: false, materialData: voiceMaterials) { _, _, _, _, _, _, matarialInfo, _ in
|
|
|
+ let materialType: String = "\(matarialInfo?["materialType"] ?? "")"
|
|
|
+ let localPath: String = "\(matarialInfo?["localPath"] ?? "")"
|
|
|
+
|
|
|
+ BFLog(message: "上传录音-录音上传返回--\(String(describing: matarialInfo))")
|
|
|
+ if matarialInfo != nil, matarialInfo?.keys.contains("localPath") ?? false, materialType == StickerType.VOICE.rawValue && localPath.contains("_noise_") {
|
|
|
+ BFLog(message: "上传录音-录音上传成功开始转化字幕")
|
|
|
+ let materialId: String = "\(matarialInfo?["materialId"] ?? "")"
|
|
|
+ let duration: Float64 = Float64("\(matarialInfo?["duration"] ?? "")") ?? 0
|
|
|
+ PQVideoEditViewModel.transferAudioMaterialToTextData(Int64(materialId) ?? 0, dutation: duration) { _, _, subTitleList, _ in
|
|
|
+ BFLog(message: "上传录音-字幕转化完成:\(subTitleList.count)")
|
|
|
+
|
|
|
+ if subTitleList.count > 0 {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|