3 Commits

Author SHA1 Message Date
starmen1265 d039537f1d docs(backlog): add semantic segmentation requirement
Add requirement for improving SRT semantic segmentation:
- Current rule-based approach cannot identify topic transitions
- Document 4 potential solutions with trade-offs
- Recommended approach: two-stage with optional LLM

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 23:20:19 +08:00
starmen1265 a2ca45523b fix(srt): add punctuation requirement to ASR correction prompt
- Update CORRECTION_PROMPT to explicitly require adding punctuation
- Fix missing punctuation in thunderstorm and lightning sections

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 23:20:07 +08:00
starmen1265 0752f8b38f debug: add API response logging to investigate content vs reasoning_content
PR Test / lint (pull_request) Successful in 2s
2026-03-21 22:47:15 +08:00
3 changed files with 73 additions and 1 deletions
@@ -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
+8
View File
@@ -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 可能包含思考过程和分析
+5 -1
View File
@@ -26,7 +26,11 @@ class AIClientProtocol(Protocol):
# 纠错 Prompt 模板
CORRECTION_PROMPT = """你是一个文本校对专家。以下是语音识别生成的字幕,可能包含识别错误。
请只纠正明显的错误(如同音字、漏字、错字),不要改变原意和风格。
请执行以下任务:
1. 纠正明显的错误(如同音字、漏字、错字)
2. 添加适当的标点符号(逗号、句号、顿号等)
3. 不要改变原意和风格
原文:
{text}