feat: Add smart paragraph merging mode with AI grouping
Some checks failed
Deploy Documentation / deploy (push) Has been cancelled

- Add "smart" split mode that uses LLM to intelligently merge related paragraphs
- Implement two-step approach: analyze text structure, then group by semantic relevance
- Add paragraph_merging.py with analysis and grouping prompts
- Update UI to support smart mode selection with auto-detect hint
- Add i18n translations for smart mode (en_US, zh_CN)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
empty
2026-01-17 00:19:46 +08:00
parent 3a8ec576ee
commit 3d3aba3670
8 changed files with 427 additions and 6 deletions

View File

@@ -65,6 +65,7 @@ def render_content_input():
"paragraph": tr("split.mode_paragraph"),
"line": tr("split.mode_line"),
"sentence": tr("split.mode_sentence"),
"smart": tr("split.mode_smart"),
}
split_mode = st.selectbox(
tr("split.mode_label"),
@@ -73,8 +74,16 @@ def render_content_input():
index=0, # Default to paragraph mode
help=tr("split.mode_help")
)
# Show info for smart mode (auto-detect segment count)
if split_mode == "smart":
st.info(tr("split.smart_auto_hint"))
target_segments = None # Auto-detect
else:
target_segments = None # Not used for other modes
else:
split_mode = "paragraph" # Default for generate mode (not used)
target_segments = None
# Title input (optional for both modes)
title = st.text_input(
@@ -105,7 +114,8 @@ def render_content_input():
"text": text,
"title": title,
"n_scenes": n_scenes,
"split_mode": split_mode
"split_mode": split_mode,
"target_segments": target_segments
}
else:

View File

@@ -52,6 +52,7 @@ def render_single_output(pixelle_video, video_params):
title = video_params.get("title")
n_scenes = video_params.get("n_scenes", 5)
split_mode = video_params.get("split_mode", "paragraph")
target_segments = video_params.get("target_segments", 8)
bgm_path = video_params.get("bgm_path")
bgm_volume = video_params.get("bgm_volume", 0.2)
@@ -116,6 +117,7 @@ def render_single_output(pixelle_video, video_params):
"title": title if title else None,
"n_scenes": n_scenes,
"split_mode": split_mode,
"target_segments": target_segments,
"media_workflow": workflow_key,
"frame_template": frame_template,
"prompt_prefix": prompt_prefix,
@@ -222,6 +224,7 @@ def render_single_output(pixelle_video, video_params):
"title": title if title else None,
"n_scenes": n_scenes,
"split_mode": split_mode,
"target_segments": target_segments,
"media_workflow": workflow_key,
"frame_template": frame_template,
"prompt_prefix": prompt_prefix,

View File

@@ -26,6 +26,8 @@
"split.mode_paragraph": "📄 By Paragraph (\\n\\n)",
"split.mode_line": "📝 By Line (\\n)",
"split.mode_sentence": "✂️ By Sentence (。.!?)",
"split.mode_smart": "🧠 Smart Merge (AI Grouping)",
"split.smart_auto_hint": "🤖 AI will analyze text structure, recommend optimal segment count, and intelligently merge related paragraphs (dialogues, same scene)",
"input.content": "Content",
"input.content_placeholder": "Used directly without modification (split by strategy below)\nExample:\nHello everyone, today I'll share three study tips.\n\nThe first tip is focus training, meditate for 10 minutes daily.\n\nThe second tip is active recall, review immediately after learning.",
"input.content_help": "Provide your own content for video generation",

View File

@@ -26,6 +26,8 @@
"split.mode_paragraph": "📄 按段落(\\n\\n",
"split.mode_line": "📝 按行(\\n",
"split.mode_sentence": "✂️ 按句号(。.!?",
"split.mode_smart": "🧠 智能合并AI 分组)",
"split.smart_auto_hint": "🤖 AI 将自动分析文本结构,推荐最佳分镜数量,并智能合并相关段落(对话、同一场景)",
"input.content": "内容",
"input.content_placeholder": "直接使用,不做改写(根据下方分割方式切分)\n例如\n大家好今天跟你分享三个学习技巧。\n\n第一个技巧是专注力训练每天冥想10分钟。\n\n第二个技巧是主动回忆学完立即复述。",
"input.content_help": "提供您自己的内容用于视频生成",