Compare commits
3 Commits
8d5beadcc7
..
v1.5
| Author | SHA1 | Date | |
|---|---|---|---|
| d039537f1d | |||
| a2ca45523b | |||
| 0752f8b38f |
@@ -0,0 +1,60 @@
|
||||
# Semantic Segmentation for SRT Processing
|
||||
|
||||
**Status:** Backlog
|
||||
**Priority:** Medium
|
||||
**Source:** User feedback during v1.5 testing
|
||||
|
||||
## Problem
|
||||
|
||||
Current `SemanticSegmenter` uses simple heuristic rules:
|
||||
- Time gap > 3 seconds
|
||||
- Paragraph length > 500 characters
|
||||
|
||||
This approach cannot identify **semantic topic transitions**.
|
||||
|
||||
### Example Case
|
||||
|
||||
Video: BV1MiPSz2ErY (科学透镜 - 5 topics in one video)
|
||||
1. 银河系中心的超大黑洞人马座A*其实不是黑洞
|
||||
2. 银河系和仙女座星系等构成的本星系群陷入巨大物质薄片
|
||||
3. 科学家为世界上97%的建筑生成3D模型
|
||||
4. 雷暴的形成
|
||||
5. 闪电的形成
|
||||
|
||||
Current segmentation mixes these topics together.
|
||||
|
||||
## Potential Solutions
|
||||
|
||||
### Option 1: Transition Keyword Detection (Simple)
|
||||
- Detect common transition phrases: "接下来", "另外", "第二个", etc.
|
||||
- **Pros:** Fast, no API calls
|
||||
- **Cons:** Low accuracy, many videos lack explicit transitions
|
||||
|
||||
### Option 2: LLM-Based Segmentation (Accurate)
|
||||
- Ask LLM to analyze entire subtitle and identify topic boundaries
|
||||
- **Pros:** Highest accuracy, understands semantics
|
||||
- **Cons:** Extra API cost, token limits for long videos
|
||||
|
||||
### Option 3: Two-Stage Approach (Balanced)
|
||||
- Stage 1: Simple rule-based segmentation (current)
|
||||
- Stage 2: LLM checks paragraph beginnings for new topics
|
||||
- **Pros:** Most cases use simple rules, LLM only for key decisions
|
||||
- **Cons:** More complex implementation
|
||||
|
||||
### Option 4: Embedding-Based Similarity
|
||||
- Calculate semantic similarity between adjacent paragraphs
|
||||
- Low similarity = topic boundary
|
||||
- **Pros:** No LLM API calls, runs locally
|
||||
- **Cons:** Requires embedding model, implementation complexity
|
||||
|
||||
## Recommendation
|
||||
|
||||
**Phase 1 (Quick Win):** Transition keyword detection + improve prompt
|
||||
|
||||
**Phase 2 (Full Solution):** Two-stage approach with optional LLM semantic segmentation
|
||||
|
||||
## Success Criteria
|
||||
|
||||
1. Topics are separated correctly
|
||||
2. Each paragraph covers a single coherent topic
|
||||
3. No false splits within a topic
|
||||
@@ -116,6 +116,14 @@ class SimpleAIClient:
|
||||
data = response.json()
|
||||
message = data.get('choices', [{}])[0].get('message', {})
|
||||
|
||||
# 调试:打印完整的 API 响应结构
|
||||
print(f"[DEBUG] disable_reasoning={disable_reasoning}", file=sys.stderr)
|
||||
print(f"[DEBUG] message keys: {list(message.keys())}", file=sys.stderr)
|
||||
if 'content' in message:
|
||||
print(f"[DEBUG] content 长度: {len(message['content'])}, 前200字符: {message['content'][:200]}", file=sys.stderr)
|
||||
if 'reasoning_content' in message:
|
||||
print(f"[DEBUG] reasoning_content 长度: {len(message['reasoning_content'])}, 前200字符: {message['reasoning_content'][:200]}", file=sys.stderr)
|
||||
|
||||
# 返回 content 字段
|
||||
# 当禁用思考模式时,content 包含直接答案
|
||||
# 当启用思考模式时,content 可能包含思考过程和分析
|
||||
|
||||
@@ -26,7 +26,11 @@ class AIClientProtocol(Protocol):
|
||||
|
||||
# 纠错 Prompt 模板
|
||||
CORRECTION_PROMPT = """你是一个文本校对专家。以下是语音识别生成的字幕,可能包含识别错误。
|
||||
请只纠正明显的错误(如同音字、漏字、错字),不要改变原意和风格。
|
||||
|
||||
请执行以下任务:
|
||||
1. 纠正明显的错误(如同音字、漏字、错字)
|
||||
2. 添加适当的标点符号(逗号、句号、顿号等)
|
||||
3. 不要改变原意和风格
|
||||
|
||||
原文:
|
||||
{text}
|
||||
|
||||
Reference in New Issue
Block a user