|
@@ -235,10 +235,23 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
lazy var subtitleEditView:BFSubtitleEditView = {
|
|
lazy var subtitleEditView:BFSubtitleEditView = {
|
|
let subtitleEditView = BFSubtitleEditView.init(frame: CGRect.init(x: 0, y: 0, width: cScreenWidth, height: cScreenHeigth))
|
|
let subtitleEditView = BFSubtitleEditView.init(frame: CGRect.init(x: 0, y: 0, width: cScreenWidth, height: cScreenHeigth))
|
|
subtitleEditView.isHidden = true
|
|
subtitleEditView.isHidden = true
|
|
|
|
+
|
|
return subtitleEditView
|
|
return subtitleEditView
|
|
}()
|
|
}()
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ //显示字幕
|
|
|
|
+ lazy var subtitleLabel:PQSubTitleLabel = {
|
|
|
|
+ let subtitleLabel = PQSubTitleLabel.init(frame: CGRect.init(x: 0, y: 300, width: cScreenWidth, height: 60))
|
|
|
|
+ subtitleLabel.backgroundColor = .clear
|
|
|
|
+ subtitleLabel.textAlignment = .center
|
|
|
|
|
|
|
|
+ return subtitleLabel
|
|
|
|
+
|
|
|
|
+ }()
|
|
|
|
+
|
|
|
|
+ //录音识别文字
|
|
|
|
+ let speechTranscriberUtil:PQSpeechTranscriberUtil = PQSpeechTranscriberUtil.init()
|
|
|
|
+
|
|
lazy var progressThumV : BFVideoThumbProgressView = {
|
|
lazy var progressThumV : BFVideoThumbProgressView = {
|
|
let vv = BFVideoThumbProgressView(frame: CGRect(x: 0, y: 54, width: cScreenWidth, height: 50))
|
|
let vv = BFVideoThumbProgressView(frame: CGRect(x: 0, y: 54, width: cScreenWidth, height: 50))
|
|
vv.dragScrollProgressHandle = {[weak self] process in
|
|
vv.dragScrollProgressHandle = {[weak self] process in
|
|
@@ -305,6 +318,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
view.addSubview(subtitleBtn)
|
|
view.addSubview(subtitleBtn)
|
|
view.addSubview(soundSettingBtn)
|
|
view.addSubview(soundSettingBtn)
|
|
view.addSubview(subtitleView)
|
|
view.addSubview(subtitleView)
|
|
|
|
+ view.addSubview(subtitleLabel)
|
|
|
|
|
|
|
|
|
|
bottomeView.addSubview(progreddL)
|
|
bottomeView.addSubview(progreddL)
|
|
@@ -485,10 +499,12 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
}
|
|
}
|
|
//声音设置
|
|
//声音设置
|
|
@objc func soundSetting(){
|
|
@objc func soundSetting(){
|
|
- BFLog(message: "设置字幕")
|
|
|
|
|
|
+ BFLog(message: "设置声音")
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
@objc func startRecord(){
|
|
@objc func startRecord(){
|
|
|
|
+
|
|
BFLog(1, message: "start \(UIControl.Event.touchDown)")
|
|
BFLog(1, message: "start \(UIControl.Event.touchDown)")
|
|
isRecording = true
|
|
isRecording = true
|
|
|
|
|
|
@@ -514,12 +530,18 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
// movie?.startProcessing()
|
|
// movie?.startProcessing()
|
|
assetPlayer?.volume = 0
|
|
assetPlayer?.volume = 0
|
|
assetPlayer?.play()
|
|
assetPlayer?.play()
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ speechTranscriberUtil.delegate = self
|
|
|
|
+ speechTranscriberUtil.startTranscriber()
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@objc func endRecord(){
|
|
@objc func endRecord(){
|
|
|
|
|
|
-
|
|
|
|
|
|
+ speechTranscriberUtil.endTranscriber()
|
|
// 存储录音
|
|
// 存储录音
|
|
|
|
|
|
recorderManager.endRecord()
|
|
recorderManager.endRecord()
|
|
@@ -887,3 +909,36 @@ extension BFRecordScreenController : AVAudioPlayerDelegate {
|
|
BFLog(1, message: "录音播放结束")
|
|
BFLog(1, message: "录音播放结束")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // MARK: - 视图参数
|
|
|
|
+extension BFRecordScreenController:PQSpeechTranscriberUtilDelegate{
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public func eventCallback(_ event: PQSpeechTranscriberUtil, asrResult: String) {
|
|
|
|
+ let dicResult:Dictionary<String,Any>? = jsonStringToDictionary(asrResult)
|
|
|
|
+
|
|
|
|
+ let payload = dicResult?["payload"] as? Dictionary<String,Any>
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ BFLog(message: "识别结果:dicResult is \(String(describing: dicResult)) \((payload?["result"])!)")
|
|
|
|
+ DispatchQueue.main.async {
|
|
|
|
+
|
|
|
|
+ let attributedText = NSMutableAttributedString(string: (payload?["result"]) as! String,attributes: [.font: UIFont.systemFont(ofSize: 34),.strokeWidth:-3,.strokeColor:UIColor.orange])
|
|
|
|
+ self.subtitleLabel.attributedText = attributedText
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// BFLog(message: "ui asrResult is \(String(describing: dicResult)) 结果为:\(Dictionary<String,Dictionary>dicResult?["payload"]")"
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+}
|