mirror of
https://github.com/linyqh/NarratoAI.git
synced 2026-02-10 00:05:39 +00:00
合并来自 Jrt 的代码优化
- 修复了视频审查功能重新生成无效的问题
This commit is contained in:
parent
578146ddc9
commit
b3a73089e2
@ -391,7 +391,8 @@ with left_panel:
|
|||||||
try:
|
try:
|
||||||
data = json.loads(input_json)
|
data = json.loads(input_json)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
raise ValueError(f"视频脚本格式错误,请检查脚本是否符合 JSON 格式;{err} \n\n{traceback.format_exc()}")
|
raise ValueError(
|
||||||
|
f"视频脚本格式错误,请检查脚本是否符合 JSON 格式;{err} \n\n{traceback.format_exc()}")
|
||||||
|
|
||||||
# 检查是否是一个列表
|
# 检查是否是一个列表
|
||||||
if not isinstance(data, list):
|
if not isinstance(data, list):
|
||||||
@ -414,8 +415,8 @@ with left_panel:
|
|||||||
# 刷新页面
|
# 刷新页面
|
||||||
st.rerun()
|
st.rerun()
|
||||||
|
|
||||||
with button_columns[1]:
|
|
||||||
if st.button(tr("Crop Video"), key="auto_crop_video", use_container_width=True):
|
def caijian():
|
||||||
with st.spinner(tr("裁剪视频中...")):
|
with st.spinner(tr("裁剪视频中...")):
|
||||||
st.session_state['task_id'] = str(uuid4())
|
st.session_state['task_id'] = str(uuid4())
|
||||||
|
|
||||||
@ -440,6 +441,11 @@ with left_panel:
|
|||||||
else:
|
else:
|
||||||
st.error(tr("请先生成视频脚本"))
|
st.error(tr("请先生成视频脚本"))
|
||||||
|
|
||||||
|
|
||||||
|
with button_columns[1]:
|
||||||
|
if st.button(tr("Crop Video"), key="auto_crop_video", use_container_width=True):
|
||||||
|
caijian()
|
||||||
|
|
||||||
# 新中间面板
|
# 新中间面板
|
||||||
with middle_panel:
|
with middle_panel:
|
||||||
with st.container(border=True):
|
with st.container(border=True):
|
||||||
@ -723,17 +729,30 @@ with st.expander(tr("Video Check"), expanded=False):
|
|||||||
text2 = st.text_area(tr("Picture description"), value=initial_picture, height=20)
|
text2 = st.text_area(tr("Picture description"), value=initial_picture, height=20)
|
||||||
text3 = st.text_area(tr("Narration"), value=initial_narration, height=100)
|
text3 = st.text_area(tr("Narration"), value=initial_narration, height=100)
|
||||||
|
|
||||||
# 清空文本框按钮
|
# 重新生成按钮
|
||||||
if st.button(tr("Rebuild"), key=f"button_{index}"):
|
if st.button(tr("Rebuild"), key=f"button_{index}"):
|
||||||
print(123123)
|
# 更新video_list中的对应项
|
||||||
# with st.spinner(tr("大模型生成中...")):
|
video_list[index]['timestamp'] = text1
|
||||||
|
video_list[index]['picture'] = text2
|
||||||
|
video_list[index]['narration'] = text3
|
||||||
|
|
||||||
|
for video in video_list:
|
||||||
|
if 'path' in video:
|
||||||
|
del video['path']
|
||||||
|
# 更新session_state以确保更改被保存
|
||||||
|
st.session_state['video_clip_json'] = utils.to_json(video_list)
|
||||||
|
# 替换原JSON 文件
|
||||||
|
with open(video_json_file, 'w', encoding='utf-8') as file:
|
||||||
|
json.dump(video_list, file, ensure_ascii=False, indent=4)
|
||||||
|
caijian()
|
||||||
|
st.rerun()
|
||||||
|
|
||||||
start_button = st.button(tr("Generate Video"), use_container_width=True, type="primary")
|
start_button = st.button(tr("Generate Video"), use_container_width=True, type="primary")
|
||||||
if start_button:
|
if start_button:
|
||||||
config.save_config()
|
config.save_config()
|
||||||
task_id = st.session_state.get('task_id')
|
task_id = st.session_state.get('task_id')
|
||||||
if st.session_state.get('video_script_json_path') is not None:
|
if st.session_state.get('video_script_json_path') is not None:
|
||||||
params.video_clip_json = st.session_state.get('video_script_json_path')
|
params.video_clip_json = st.session_state.get('video_clip_json')
|
||||||
|
|
||||||
logger.debug(f"当前的脚本为:{params.video_clip_json}")
|
logger.debug(f"当前的脚本为:{params.video_clip_json}")
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user