|
@@ -471,6 +471,17 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
voiceSettingView.isHidden = true
|
|
|
return voiceSettingView
|
|
|
}()
|
|
|
+ //显示选中发音人的头像
|
|
|
+ lazy var voiceIconView: UIImageView = {
|
|
|
+ let voiceIconView = UIImageView()
|
|
|
+ voiceIconView.addCorner(corner: 25 / 2)
|
|
|
+ return voiceIconView
|
|
|
+ }()
|
|
|
+ //tts 服务
|
|
|
+ var tts:BFTTSManager?
|
|
|
+ //当前选择的发音人
|
|
|
+ var mSelectVoiced:PQVoiceModel?
|
|
|
+
|
|
|
|
|
|
// 编辑字幕
|
|
|
lazy var subtitleEditView: BFSubtitleEditView = {
|
|
@@ -671,6 +682,9 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
BFLog(message: "nls appkey is \(appkey), token is \(token)")
|
|
|
wself.NeoNuiAPPID = appkey
|
|
|
wself.NeoNuiToken = token
|
|
|
+
|
|
|
+ wself.tts = BFTTSManager.init(nui: token, appid: appkey)
|
|
|
+ wself.tts?.delegate = wself
|
|
|
}
|
|
|
|
|
|
initlizeRecordManager()
|
|
@@ -688,6 +702,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
view.addSubview(soundSettingBtn)
|
|
|
if(BFLocalizedUtil.currentLanguage() == "zh"){
|
|
|
view.addSubview(voiceSettingBtn)
|
|
|
+ voiceSettingBtn.addSubview(voiceIconView)
|
|
|
}
|
|
|
|
|
|
view.addSubview(cameraFlipBtn)
|
|
@@ -769,17 +784,68 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
view.addSubview(audioQueueRecoderLabel)
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ // add by ak 发音人相关操作
|
|
|
+ BFRecordScreenViewModel.getAllVoiceCates { [weak self] categorys, voices in
|
|
|
+ guard let wself = self else { return }
|
|
|
+ wself.voiceSettingView.categorys = categorys
|
|
|
+ wself.voiceSettingView.voices = voices
|
|
|
+
|
|
|
+ }
|
|
|
voiceSettingView.voiceSettingCallBack = {[weak self] actionType ,selectVoice in
|
|
|
guard let wself = self else { return }
|
|
|
- if actionType == .VoiceSettingActionConfirm{
|
|
|
- BFLog(2, message: "确认发音人操作")
|
|
|
+
|
|
|
+ if actionType == .VoiceSettingActionConfirm{//要生成真实音频文件
|
|
|
+ BFLog(2, message: "确认选择发音人操作")
|
|
|
+ wself.mSelectVoiced = selectVoice
|
|
|
+ if(wself.mSelectVoiced != nil){
|
|
|
+ wself.tts?.startTTS("", taskId: "", isAudition: false,fontName: selectVoice?.voice ?? "")
|
|
|
+
|
|
|
+ }
|
|
|
+ wself.voiceIconView.setNetImage(url: "\(wself.mSelectVoiced?.avatarUrl ?? "")")
|
|
|
+
|
|
|
+ wself.tts?.stopTTS("")
|
|
|
+ wself.voiceSettingView.flushSelectVoiceStatus(voiceStatue: .isNormal)
|
|
|
+
|
|
|
|
|
|
}else if actionType == .voiceSettingActionCancel{
|
|
|
BFLog(2, message: "取消发音人操作")
|
|
|
-
|
|
|
+
|
|
|
}else if actionType == .voiceSettingActionDelete{
|
|
|
BFLog(2, message: "删除发音人操作")
|
|
|
+ wself.voiceIconView.image = nil
|
|
|
+ //停止文字转换
|
|
|
+ wself.tts?.stopTTS("")
|
|
|
+ }else if actionType == .VoiceSettingActionSelected{//要进行试听或暂停操作
|
|
|
+ BFLog(2, message: "选择了一个发音人操作")
|
|
|
+ if(wself.mSelectVoiced == nil){
|
|
|
+ //首次选直接转
|
|
|
+ wself.tts?.startTTS("", taskId: "", isAudition: true,fontName: selectVoice?.voice ?? "")
|
|
|
+ wself.voiceSettingView.flushSelectVoiceStatus(voiceStatue: .isLoading)
|
|
|
+ }else{
|
|
|
+
|
|
|
+
|
|
|
+ if(wself.mSelectVoiced == selectVoice){ //是同一个发音人暂停
|
|
|
+
|
|
|
+ BFLog(message: "试听播放器状态\(String(describing: wself.tts?.voicePlayer.state.rawValue) )")
|
|
|
+ if(wself.tts?.voicePlayer.state == PlayerState.paused){
|
|
|
+ wself.tts?.startTTS("", taskId: "", isAudition: true,fontName: selectVoice?.voice ?? "")
|
|
|
+ wself.voiceSettingView.flushSelectVoiceStatus(voiceStatue: .isLoading)
|
|
|
+
|
|
|
+ }else if (wself.tts?.voicePlayer.state == PlayerState.playing){
|
|
|
+ wself.tts?.stopTTS("")
|
|
|
+ wself.voiceSettingView.flushSelectVoiceStatus(voiceStatue: .isPause)
|
|
|
+ }
|
|
|
+
|
|
|
+ } else{//开始试听
|
|
|
+ wself.tts?.startTTS("", taskId: "", isAudition: true,fontName: selectVoice?.voice ?? "")
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ wself.mSelectVoiced = selectVoice
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -852,6 +918,11 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
make.right.width.height.equalTo(subtitleBtn)
|
|
|
make.top.equalTo(subtitleBtn.snp.bottom).offset(18)
|
|
|
}
|
|
|
+ voiceIconView.snp.makeConstraints { make in
|
|
|
+ make.width.height.equalTo(26)
|
|
|
+ make.centerX.equalTo(voiceSettingBtn)
|
|
|
+ make.top.equalTo(voiceSettingBtn).offset(8)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
cameraFlipBtn.snp.makeConstraints { make in
|
|
@@ -1262,15 +1333,6 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
BFLog(message: "设置变音")
|
|
|
|
|
|
voiceSettingView.isHidden = false
|
|
|
-
|
|
|
-
|
|
|
- BFRecordScreenViewModel.getAllVoiceCates { [weak self] categorys, voices in
|
|
|
- guard let wself = self else { return }
|
|
|
- wself.voiceSettingView.categorys = categorys
|
|
|
- wself.voiceSettingView.voices = voices
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
}
|
|
|
|
|
@@ -2763,3 +2825,15 @@ public extension BFRecordScreenController {
|
|
|
indirectionView?.resetAllSubViews(items: itemModels[currItemModelIndex].voiceStickers, percenWidth: percenWidth, totalDuration: itemModels[currItemModelIndex].materialDuraion.seconds)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+// MARK: - TTS 试听回调
|
|
|
+extension BFRecordScreenController: BFTTSManagerDelegte{
|
|
|
+ public func playerDidStart() {
|
|
|
+ BFLog(message: "试听开始播放")
|
|
|
+ voiceSettingView.flushSelectVoiceStatus(voiceStatue: .isPlaying)
|
|
|
+ }
|
|
|
+ public func playerDidFinish() {
|
|
|
+ BFLog(message: "试听播放完成")
|
|
|
+ voiceSettingView.flushSelectVoiceStatus(voiceStatue: .isSelected)
|
|
|
+ }
|
|
|
+}
|