Commit 146a444a authored by xuanweiace's avatar xuanweiace

fix bug

parent 881ebacb
{"video_path": "F:/mystudy/Eagle/test2/\u4f55\u4ee5\u7b19\u7bab\u9ed8.mp4", "excel_path": "F:/mystudy/Eagle/test2/\u4f55\u4ee5\u7b19\u7bab\u9ed8.xlsx", "detection_info": {"detected": false, "nd_process": 0.0, "last_time": 0.0, "caption_boundings": [], "has_subtitle": true}, "speaker_info": {"speaker_id": "\u6653\u6653\uff0c\u5973\uff0c\u5e74\u8f7b\u4eba", "speaker_speed": "1.10(4.5\u5b57/\u79d2)"}}
\ No newline at end of file
{"video_path": "F:/mystudy/Eagle/test2/\u4f55\u4ee5\u7b19\u7bab\u9ed8.mp4", "excel_path": "F:/mystudy/Eagle/test2/\u4f55\u4ee5\u7b19\u7bab\u9ed8.xlsx", "detection_info": {"detected": false, "nd_process": 0.12199690880989182, "last_time": 789.32, "caption_boundings": [], "has_subtitle": true}, "speaker_info": {"speaker_id": "\u6653\u6653\uff0c\u5973\uff0c\u5e74\u8f7b\u4eba", "speaker_speed": "1.00(4\u5b57/\u79d2)"}}
\ No newline at end of file
......@@ -167,7 +167,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.pb_tableWidget.itemDoubleClicked.connect(self.pb_item_changed_by_double_clicked_slot)
self.pb_tableWidget.itemChanged.connect(self.rewriteHistory)
self.pb_tableWidget.itemChanged.connect(self.generate_audio_slot)
# todo 现在只在【旁白】tab上双击修改,会保存表格到本地,【字幕旁白】tab上不行。
# todo 现在只在【旁白】tab上双击修改,会保存表格到本地,【字幕旁白】tab上不行。(【字幕旁白】tab上无法修改旁白)
self.pb_tableWidget.itemChanged.connect(self.write2ProjectFromAside)
self.zm_tableWidget.itemDoubleClicked.connect(self.change_video_time)
self.pb_tableWidget.itemDoubleClicked.connect(self.change_video_time)
......@@ -600,7 +600,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
user_operation=True的情况:用户双击操作表格,通过【操作表格】进行增删改,通过【在此处添加旁白】来添加一行
initial_ing为true时,不会生成音频,不会写入历史记录
"""
if user_operation:
if not user_operation:
self.projectContext.initial_ing = True
header = self.projectContext.header
subtitle_list = self.projectContext.subtitle_list
......@@ -639,7 +639,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.pb_tableWidget_idx = len(aside_list)
self.zm_tableWidget_idx = len(subtitle_list)
if user_operation:
if not user_operation:
self.projectContext.initial_ing = False
def setElememtToTable(self, table: QTableWidget, elem: Element, idx: int):
......@@ -744,9 +744,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
if item is None:
print("WRONG!!!! item Is None")
return
if self.is_user_editing() == False:
return
self.set_user_edit(False)
# 不需要set为False
row = item.row() # 获取行数
col = item.column() # 获取列数 注意是column而不是col
......@@ -756,15 +757,17 @@ class MainWindow(QMainWindow, Ui_MainWindow):
return
self.excel_content_changed = True
# 合成这一段语音
self.do_generate_audio_by_aside_row(int(row))
def do_generate_audio_by_aside_row(self, row):
"""
传入pb_tableWidget的一个下标,生成对应音频
"""
from speech_synthesis import speech_synthesis, Speaker, choose_speaker
print("self.projectContext.excel_path:",
self.projectContext.excel_path)
audio_dir = os.path.dirname(self.projectContext.excel_path)
print("self.pb_tableWidget.itemAt(item.row(), 0).text()",
self.projectContext.aside_list[item.row()].st_time_sec)
wav_path = audio_dir + \
'/tmp/%.2f.wav' % float(
self.projectContext.aside_list[item.row()].st_time_sec)
self.projectContext.aside_list[int(row)].st_time_sec)
print("wav_path:", wav_path)
# speed_info = self.projectContext.speaker_speed
# 使用私有 语速
......@@ -785,6 +788,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
return self.user_editing_content or self.user_editing_aside
def set_user_edit(self, val:bool):
print("set_user_edit: ", val)
self.user_editing_content = val
self.user_editing_aside = val
......@@ -793,7 +797,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
return
if self.is_user_editing() == False:
return
self.set_user_edit(False)
# 这里不需要加,因为按照槽函数的顺序 还有一个要执行的
# self.set_user_edit(False)
if item is None:
print("WRONG!!!! item Is None")
return
......@@ -859,6 +864,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
return
if self.is_user_editing() == False:
return
self.set_user_edit(False)
if item is None:
print("WRONG!!!! item Is None")
return
......@@ -895,6 +901,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
def undo_slot(self):
self.can_write_history = False
self.user_editing_aside = True
record = self.projectContext.history_pop()
print('[undo_slot] record=%s' % (record.to_string()))
item = QTableWidgetItem(record.old_str)
......@@ -906,6 +913,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
def redo_slot(self):
self.can_write_history = False
self.user_editing_aside = True
record = self.projectContext.history_redo()
if record is None:
self.action_redo.setEnabled(False)
......@@ -1009,6 +1017,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
idx += 1
self.projectContext.aside_list.insert(idx, new_element)
self.pb_tableWidget_idx =idx
self.do_generate_audio_by_aside_row(idx)
else:
idx = 0
while idx < len(self.projectContext.subtitle_list):
......@@ -1036,6 +1045,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
if to_be_modify_element.equalTo(self.projectContext.aside_list[i]):
self.pb_tableWidget_idx =i
self.setElememtToTable(self.pb_tableWidget, self.projectContext.aside_list[i], i)
self.do_generate_audio_by_aside_row(i)
break
else:
for i in range(len(self.projectContext.subtitle_header)):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment