From 420f9392e395cbd3abb7307c1edf1a31b50a0ef7 Mon Sep 17 00:00:00 2001 From: linyq Date: Mon, 18 Nov 2024 12:19:48 +0800 Subject: [PATCH] =?UTF-8?q?feat(webui):=20=E6=96=B0=E5=A2=9E=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E8=AE=BE=E7=BD=AE=E5=8A=9F=E8=83=BD=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=85=B3=E9=94=AE=E5=B8=A7=E6=8F=90=E5=8F=96-=20?= =?UTF-8?q?=E5=9C=A8=20script=5Fsettings.py=20=E4=B8=AD=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BA=86=E4=B8=89=E4=B8=AA=E6=96=B0=E7=9A=84=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E6=A1=86=EF=BC=8C=E7=94=A8=E4=BA=8E=E8=AE=BE=E7=BD=AE=20skip?= =?UTF-8?q?=5Fseconds=E3=80=81threshold=20=E5=92=8C=20vision=5Fbatch=5Fsiz?= =?UTF-8?q?e-=20=E6=9B=B4=E6=96=B0=E4=BA=86=E5=85=B3=E9=94=AE=E5=B8=A7?= =?UTF-8?q?=E6=8F=90=E5=8F=96=E8=BF=87=E7=A8=8B=EF=BC=8C=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E6=96=B0=E8=AE=BE=E7=BD=AE=E7=9A=84=E5=8F=82=E6=95=B0=E6=9B=BF?= =?UTF-8?q?=E4=BB=A3=E4=BA=86=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E5=9B=BA=E5=AE=9A=E5=80=BC=20-=20=E5=9C=A8=20i18n/zh.?= =?UTF-8?q?json=20=E4=B8=AD=E6=B7=BB=E5=8A=A0=E4=BA=86=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E7=BF=BB=E8=AF=91=EF=BC=8C=E7=A1=AE=E4=BF=9D=E6=96=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E6=94=AF=E6=8C=81=E4=B8=AD=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webui/components/script_settings.py | 45 +++++++++++++++++++++++++---- webui/i18n/zh.json | 13 +++++++-- 2 files changed, 50 insertions(+), 8 deletions(-) diff --git a/webui/components/script_settings.py b/webui/components/script_settings.py index 4e4aea6..67a2e16 100644 --- a/webui/components/script_settings.py +++ b/webui/components/script_settings.py @@ -205,6 +205,40 @@ def render_video_details(tr): def render_script_buttons(tr, params): """渲染脚本操作按钮""" + # 新增三个输入框,放在同一行 + input_cols = st.columns(3) + + with input_cols[0]: + skip_seconds = st.number_input( + "skip_seconds", + min_value=0, + value=st.session_state.get('skip_seconds', config.frames.get('skip_seconds', 0)), + help=tr("Skip the first few seconds"), + key="skip_seconds_input" + ) + st.session_state['skip_seconds'] = skip_seconds + + with input_cols[1]: + threshold = st.number_input( + "threshold", + min_value=0, + value=st.session_state.get('threshold', config.frames.get('threshold', 30)), + help=tr("Difference threshold"), + key="threshold_input" + ) + st.session_state['threshold'] = threshold + + with input_cols[2]: + vision_batch_size = st.number_input( + "vision_batch_size", + min_value=1, + max_value=20, + value=st.session_state.get('vision_batch_size', config.frames.get('vision_batch_size', 5)), + help=tr("Vision processing batch size"), + key="vision_batch_size_input" + ) + st.session_state['vision_batch_size'] = vision_batch_size + # 生成/加载按钮 script_path = st.session_state.get('video_clip_json_path', '') if script_path == "auto": @@ -287,7 +321,6 @@ def generate_script(tr, params): with st.spinner("正在生成脚本..."): if not params.video_origin_path: st.error("请先选择视频文件") - st.stop() return # ===================提取键帧=================== @@ -323,8 +356,8 @@ def generate_script(tr, params): # 处理视频并提取关键帧 processor.process_video_pipeline( output_dir=video_keyframes_dir, - skip_seconds=config.frames.get("skip_seconds", 0), - threshold=config.frames.get("threshold", 30) + skip_seconds=st.session_state.get('skip_seconds'), + threshold=st.session_state.get('threshold') ) else: processor = video_processor.VideoProcessor(params.video_origin_path) @@ -353,7 +386,7 @@ def generate_script(tr, params): except Exception as cleanup_err: logger.error(f"清理失败的关键帧目录时出错: {cleanup_err}") - raise Exception(f"关键帧提取��败: {str(e)}") + raise Exception(f"关键帧提取失败: {str(e)}") # 根据不同的 LLM 提供商处理 vision_llm_provider = st.session_state.get('vision_llm_providers').lower() @@ -374,7 +407,7 @@ def generate_script(tr, params): analyzer = vision_analyzer.VisionAnalyzer( model_name=vision_model, - api_key=vision_api_key + api_key=vision_api_key, ) update_progress(40, "正在分析关键帧...") @@ -388,7 +421,7 @@ def generate_script(tr, params): analyzer.analyze_images( images=keyframe_files, prompt=config.app.get('vision_analysis_prompt'), - batch_size=config.frames.get("vision_batch_size", 5) + batch_size=config.frames.get("vision_batch_size", st.session_state.get('vision_batch_size', 5)) ) ) loop.close() diff --git a/webui/i18n/zh.json b/webui/i18n/zh.json index 48b50cf..c3c06fd 100644 --- a/webui/i18n/zh.json +++ b/webui/i18n/zh.json @@ -125,6 +125,15 @@ "Text API Key": "文案生成 API 密钥", "Text Base URL": "文案生成接口地址", "Text Model Name": "文案生成模型名称", - "Account ID": "账户 ID" + "Account ID": "账户 ID", + "Skip the first few seconds": "跳过开头多少秒", + "Difference threshold": "差异阈值", + "Vision processing batch size": "视觉处理批次大小", + "Test Connection": "测试连接", + "gemini model is available": "Gemini 模型可用", + "gemini model is not available": "Gemini 模型不可用", + "NarratoAPI is available": "NarratoAPI 可用", + "NarratoAPI is not available": "NarratoAPI 不可用", + "Unsupported provider": "不支持的提供商" } -} \ No newline at end of file +}