|
@@ -774,12 +774,33 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
// 更新缓存数据
|
|
|
if index < (wself.itemModels[wself.currItemModelIndex ].titleStickers.count ) {
|
|
|
+ //add by ak 1刷新变音缓存
|
|
|
+ let deleteTaskids:[String]? = wself.tts?.changedTitle(newtext, oldText: wself.itemModels[wself.currItemModelIndex ].titleStickers[index].text) as? [String]
|
|
|
+
|
|
|
+ //2刷新变量后的老音频数据
|
|
|
+ if((deleteTaskids?.count ?? 0) > 0){
|
|
|
+ for taskid in deleteTaskids!{
|
|
|
+ wself.itemModels[wself.currItemModelIndex].voiceChangeStickers = wself.itemModels[wself.currItemModelIndex].voiceChangeStickers.filter { (model) -> Bool in
|
|
|
+ if model.ttsTaskID == taskid {
|
|
|
+ //fase 是不要
|
|
|
+ return false
|
|
|
+ }else {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
if newtext.count == 0 {
|
|
|
// 删除数据
|
|
|
BFLog(message: "清空字幕操作要删除原字幕 sticker 数据")
|
|
|
wself.itemModels[wself.currItemModelIndex ].titleStickers.remove(at: index)
|
|
|
wself.subtitleLabel.text = ""
|
|
|
} else {
|
|
|
+ wself.loadingView.isHidden = false
|
|
|
+ wself.tts?.runNextTask()
|
|
|
+ //更新已经变音数据
|
|
|
// 更新数据
|
|
|
wself.itemModels[wself.currItemModelIndex ].titleStickers[index].text = newtext
|
|
|
wself.subtitleLabel.text = newtext
|
|
@@ -819,6 +840,18 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
if actionType == .VoiceSettingActionConfirm{//要生成真实音频文件
|
|
|
wself.tts?.stopTTS("")
|
|
|
BFLog(2, message: "确认选择发音人操作")
|
|
|
+
|
|
|
+ //切换了发音人
|
|
|
+ if(wself.mSelectVoiced != selectVoice){
|
|
|
+ BFLog(2, message: "老发音人\(wself.mSelectVoiced?.name ?? "") 新发音人\(selectVoice?.name ?? "")")
|
|
|
+ //1,清空发音人缓存数据
|
|
|
+ wself.tts?.changedVoice(selectVoice?.voice ?? "")
|
|
|
+ //2,清空已经生成的变音sticker
|
|
|
+ for itemModel in wself.itemModels{
|
|
|
+ itemModel.voiceChangeStickers.removeAll()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
wself.mSelectVoiced = selectVoice
|
|
|
wself.voiceSettingView.flushSelectVoiceStatus(voiceStatue: .isSelected)
|
|
|
if(wself.mSelectVoiced != nil){
|
|
@@ -850,9 +883,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
//首次选直接转
|
|
|
wself.tts?.startTTS("", taskId: "", isAudition: true,fontName: selectVoice?.voice ?? "")
|
|
|
wself.voiceSettingView.flushSelectVoiceStatus(voiceStatue: .isLoading)
|
|
|
- }else{
|
|
|
-
|
|
|
-
|
|
|
+ }else{
|
|
|
if(wself.mSelectVoiced == selectVoice){ //是同一个发音人暂停
|
|
|
|
|
|
BFLog(message: "试听播放器状态\(String(describing: wself.tts?.voicePlayer.state.rawValue) )")
|
|
@@ -870,8 +901,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
wself.voiceSettingView.flushSelectVoiceStatus(voiceStatue: .isLoading)
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- wself.mSelectVoiced = selectVoice
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -1045,18 +1075,19 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
newSubtitle.setting = wself.subtitleSettingView.subtitle.setting
|
|
|
tempItem?.titleStickers.append(newSubtitle)
|
|
|
|
|
|
- //add by ak 有字幕&设置发音人 添加到转换缓存
|
|
|
- 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)
|
|
|
+ //add by ak 有字幕& 没有设置发音人也要添加到转换缓存
|
|
|
+ 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
|
|
|
+ if(wself.mSelectVoiced == nil){
|
|
|
+ wself.tts?.pushTaskCache(ttsModel, autoTranslate:false)
|
|
|
+ }else{
|
|
|
+ wself.tts?.pushTaskCache(ttsModel, autoTranslate:true)
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2784,11 +2815,16 @@ extension BFRecordScreenController: BFTTSManagerDelegte{
|
|
|
voice.wavFilePath = model.wavFilePath
|
|
|
voice.startCMTime = model.timelineIn
|
|
|
voice.endCMTime = model.timelineOut
|
|
|
+ voice.ttsTaskID = model.tTtaskId
|
|
|
itemModels[currItemModelIndex].voiceChangeStickers.append(voice)
|
|
|
|
|
|
//
|
|
|
loadingView.titleL.text = "变音中 \(itemModels[currItemModelIndex].voiceChangeStickers.count / itemModels[currItemModelIndex].titleStickers.count)%"
|
|
|
|
|
|
+ if(voiceChangeStickerFinish(itemIndex: currItemModelIndex)){
|
|
|
+ loadingView.isHidden = true
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/// 查看发音人文件是否已经全都完成,如果没有完成不能进行预览,合成操作
|
|
@@ -2815,7 +2851,7 @@ extension BFRecordScreenController: BFTTSManagerDelegte{
|
|
|
FinishCount += itemModel.voiceChangeStickers.count
|
|
|
}
|
|
|
}
|
|
|
- BFLog(message: "总任务数:\(AllCount) 已经完成数:\(FinishCount)")
|
|
|
+ BFLog(message: "翻译任务总数:\(AllCount) 已经完成数:\(FinishCount)")
|
|
|
if(FinishCount < AllCount){
|
|
|
isFinish = false
|
|
|
}
|