|
@@ -91,6 +91,15 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
public var assets = [PHAsset]()
|
|
|
|
|
|
+
|
|
|
+ lazy var loadingView: BFLoadingView = {
|
|
|
+ var loadingView = BFLoadingView(frame: CGRect(x: 0, y: 0, width: cScreenWidth, height: cScreenHeigth))
|
|
|
+ loadingView.isHidden = true
|
|
|
+
|
|
|
+ return loadingView
|
|
|
+ }()
|
|
|
+
|
|
|
+
|
|
|
var currItemModelIndex = 0 {
|
|
|
didSet{
|
|
|
if currItemModelIndex < 0 || currItemModelIndex >= itemModels.count{
|
|
@@ -808,12 +817,20 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
guard let wself = self else { return }
|
|
|
|
|
|
if actionType == .VoiceSettingActionConfirm{
|
|
|
+ wself.tts?.stopTTS("")
|
|
|
BFLog(2, message: "确认选择发音人操作")
|
|
|
wself.mSelectVoiced = selectVoice
|
|
|
wself.voiceSettingView.flushSelectVoiceStatus(voiceStatue: .isSelected)
|
|
|
if(wself.mSelectVoiced != nil){
|
|
|
- wself.tts?.startTTS("", taskId: "", isAudition: false,fontName: selectVoice?.voice ?? "")
|
|
|
+
|
|
|
wself.voiceIconView.setNetImage(url: "\(wself.mSelectVoiced?.avatarUrl ?? "")")
|
|
|
+ if(!wself.voiceChangeStickerFinish(itemIndex: wself.currItemModelIndex)){
|
|
|
+
|
|
|
+ wself.loadingView.loading()
|
|
|
+ }
|
|
|
+
|
|
|
+ wself.tts?.runNextTask()
|
|
|
+
|
|
|
|
|
|
}else{
|
|
|
wself.voiceIconView.image = nil
|
|
@@ -858,7 +875,9 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- }
|
|
|
+
|
|
|
+ UIApplication.shared.keyWindow?.addSubview(loadingView)
|
|
|
+}
|
|
|
|
|
|
func layoutsubview() {
|
|
|
bottomeView.snp.makeConstraints { make in
|
|
@@ -1025,6 +1044,19 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
newSubtitle.setting = wself.subtitleSettingView.subtitle.setting
|
|
|
tempItem?.titleStickers.append(newSubtitle)
|
|
|
+
|
|
|
+
|
|
|
+ if(wself.mSelectVoiced != nil){
|
|
|
+ let ttsModel = BFTTSTaskModel.init()
|
|
|
+ ttsModel.timelineIn = newSubtitle.timelineIn
|
|
|
+ ttsModel.timelineOut = newSubtitle.timelineOut
|
|
|
+ ttsModel.fontName = wself.mSelectVoiced?.voice ?? ""
|
|
|
+ ttsModel.recordId = recordId ?? ""
|
|
|
+ ttsModel.tTtaskId = getUniqueId(desc: "tTtaskId")
|
|
|
+ ttsModel.text = showText
|
|
|
+ wself.tts?.pushTaskCache(ttsModel)
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1899,8 +1931,17 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ var useVoiceStickers = [PQVoiceModel]()
|
|
|
+ if(itemModels[currItemModelIndex].voiceChangeStickers.count > 0){
|
|
|
+ useVoiceStickers = itemModels[currItemModelIndex].voiceChangeStickers
|
|
|
+ }else{
|
|
|
+ useVoiceStickers = itemModels[currItemModelIndex].voiceStickers
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
- if itemModels[currItemModelIndex].voiceStickers.first(where: { m in
|
|
|
+ if useVoiceStickers.first(where: { m in
|
|
|
CMTimeCompare(m.startCMTime, currentT) <= 0 && CMTimeCompare(currentT, m.endCMTime) <= 0
|
|
|
}) != nil {
|
|
|
if assetPlayer.volume != haveSpeakVolume {
|
|
@@ -1918,7 +1959,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- let list = itemModels[currItemModelIndex].voiceStickers.sorted { m1, m2 in
|
|
|
+ let list = useVoiceStickers.sorted { m1, m2 in
|
|
|
CMTimeCompare(m1.startCMTime, m2.startCMTime) < 0
|
|
|
}
|
|
|
let (shouldPlayRecordIndex, recordedAudio) = list.enumerated().first { model in
|
|
@@ -2725,7 +2766,7 @@ public extension BFRecordScreenController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
extension BFRecordScreenController: BFTTSManagerDelegte{
|
|
|
public func playerDidStart() {
|
|
|
BFLog(message: "试听开始播放")
|
|
@@ -2735,4 +2776,51 @@ extension BFRecordScreenController: BFTTSManagerDelegte{
|
|
|
BFLog(message: "试听播放完成")
|
|
|
voiceSettingView.flushSelectVoiceStatus(voiceStatue: .isSelected)
|
|
|
}
|
|
|
+
|
|
|
+ public func ttsFinish(_ model:BFTTSTaskModel){
|
|
|
+ BFLog(message: "文字转语音完成recordId:\(model.recordId) tttaskid:\(model.tTtaskId)")
|
|
|
+
|
|
|
+ let voice = PQVoiceModel.init()
|
|
|
+ voice.wavFilePath = model.wavFilePath
|
|
|
+ voice.startCMTime = model.timelineIn
|
|
|
+ voice.endCMTime = model.timelineOut
|
|
|
+ itemModels[currItemModelIndex].voiceChangeStickers.append(voice)
|
|
|
+
|
|
|
+
|
|
|
+ loadingView.titleL.text = "变音中 \(itemModels[currItemModelIndex].voiceChangeStickers.count / itemModels[currItemModelIndex].titleStickers.count)%"
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ func voiceChangeStickerFinish(itemIndex:Int = -100) -> Bool{
|
|
|
+ if(mSelectVoiced == nil){
|
|
|
+ return true
|
|
|
+ }
|
|
|
+
|
|
|
+ var isFinish = true
|
|
|
+
|
|
|
+ var AllCount = 0
|
|
|
+
|
|
|
+ var FinishCount = 0
|
|
|
+
|
|
|
+ if(itemIndex >= 0){
|
|
|
+ AllCount = itemModels[currItemModelIndex].titleStickers.count
|
|
|
+ FinishCount = itemModels[currItemModelIndex].voiceChangeStickers.count
|
|
|
+
|
|
|
+ }else{
|
|
|
+ for itemModel in itemModels{
|
|
|
+ AllCount += itemModel.titleStickers.count
|
|
|
+ FinishCount += itemModel.voiceChangeStickers.count
|
|
|
+ }
|
|
|
+ }
|
|
|
+ BFLog(message: "总任务数:\(AllCount) 已经完成数:\(FinishCount)")
|
|
|
+ if(FinishCount < AllCount){
|
|
|
+ isFinish = false
|
|
|
+ }
|
|
|
+
|
|
|
+ return isFinish
|
|
|
+ }
|
|
|
+
|
|
|
}
|