SRT转黑曜石代理商
一个智能代理,使用MCP(模型上下文协议)服务器集成将SRT字幕文件转换为格式良好的黑曜石笔记。
特性
- 🎬 SRT解析:通过适当的时间戳处理自动解析SRT字幕文件
- 📝 智能格式化:将字幕分组为带有时间戳的可读段落
- 🏷️ 自动标记:智能内容分类和标签分配
- 🔗 MCP集成:通过MCP服务器与Obsidian无缝集成
- 📁 文件夹组织:自动创建和组织文件夹
- 🎯 批处理:一次处理多个SRT文件
- 🛡️ 错误处理:强大的错误处理和验证
文件概述
核心组件
srt_to_obsidian_agent.py-具有SRT解析和格式化逻辑的主代理mcp_obsidian_integration.py-黑曜石增强MCP集成run_srt_agent.py-简单的CLI界面,易于使用README.md-此文档文件
安装
先决条件
- Python 3.7+
- 黑曜石,支持MCP服务器
- 访问您的黑曜石保险库目录
设置
- 下载代理文件 到目录(例如。,
/Users/pangwong/obsidian/WLB/tmp/)
- 使脚本可执行:
chmod +x run_srt_agent.py
chmod +x srt_to_obsidian_agent.py- 验证您的黑曜石保险库路径 在配置中(默认值:
/Users/pangwong/obsidian/WLB)
用法
快速开始
# Convert a single SRT file
python3 run_srt_agent.py /path/to/your/video.srt
# Convert with custom folder
python3 run_srt_agent.py /path/to/your/video.srt --folder "Projects/Transcripts"
# Convert with custom title and tags
python3 run_srt_agent.py /path/to/your/video.srt \
--title "My Custom Title" \
--tags "education" "ai" "lecture"高级用法
自定义保险库
python3 run_srt_agent.py /path/to/video.srt --vault "MyVault"禁用自动标记
python3 run_srt_agent.py /path/to/video.srt --no-auto-tags详细输出
python3 run_srt_agent.py /path/to/video.srt --verbose批处理
# Process all SRT files in a directory
python3 srt_to_obsidian_agent.py --batch /path/to/srt/directory --folder "Transcripts"真实文件示例
# Convert the Stanford CS25 lecture
python3 run_srt_agent.py \
"/Users/pangwong/obsidian/WLB/Projects/Transformers/stanford CS25/subtiles/[English (United States)] Stanford CS25_ V1 I Transformers United_ DL Models that have revolutionized NLP, CV, RL [DownSub.com].srt" \
--folder "Projects/Transformers/stanford CS25/transcripts" \
--tags "stanford" "cs25" "transformers" "education"输出格式
代理通过以下方式创建结构良好的Markdown文件:
元数据部分
## Metadata
- **Source**: original-filename.srt
- **Duration**: ~45 minutes
- **Paragraphs**: 23
- **Created**: 2024-01-15 14:30成绩单科
## Transcript
**00:15** Welcome to CS25, Transformers United. This course will cover the revolutionary deep learning models that have transformed natural language processing, computer vision, and reinforcement learning.
**02:30** Today we'll start with the history of attention mechanisms, beginning with RNNs and LSTMs, and then dive into the core concepts that make Transformers so powerful.自动生成的标签
代理会自动对内容进行分类并添加相关标签:
- 教育内容:
education,learning - 技术内容:
ai,machine-learning,transformers - 演示:
presentation,conference - 特定内容:
attention-mechanism,nlp等等。
配置
自定义代理
您可以通过编辑Python文件中的配置来修改行为:
段落分组
# In TranscriptFormatter class
time_gap_threshold = 2.0 # Seconds between paragraphs
max_paragraph_lines = 12 # Maximum lines per paragraph保险库配置
# In MCPObsidianClient class
vault_path = "/Users/pangwong/obsidian/WLB" # Your vault path自动标记规则
# In _auto_categorize_content method
educational_keywords = ['cs25', 'stanford', 'lecture', 'course']
technical_keywords = ['transformer', 'ai', 'ml', 'deep learning']MCP集成
代理使用MCP(模型上下文协议)服务器进行黑曜石集成:
可用的MCP工具
- 创建笔记:在vault中创建新注释
- 添加标签:向现有注释添加标记
- 搜索保险库:搜索vault内容
- 列出可用保管库:列出可用保管库
MCP服务器配置
代理需要以下MCP服务器:
- 服务器名称:
mcp.config.usrlocalmcp.obsidian - 工具:标准黑曜石MCP工具
故障排除
常见问题
“找不到文件”错误
❌ Error: SRT file not found: /path/to/file.srt解决方案:检查文件路径并确保SRT文件存在。
“无法读取SRT文件”错误
❌ Error: Cannot read SRT file: UnicodeDecodeError解决方案:代理将自动尝试不同的编码。如果仍然失败,请检查文件格式。
“MCP服务器不可用”错误
❌ Error: MCP server connection failed解决方案:确保Obsidian正在运行,MCP服务器配置正确。
“权限被拒绝”错误
❌ Error: Permission denied writing to vault解决方案:检查黑曜石保管库目录的文件权限。
调试模式
运行详细输出以查看详细的处理信息:
python3 run_srt_agent.py /path/to/file.srt --verbose例子
处理教育内容
# Stanford CS25 lecture
python3 run_srt_agent.py \
"stanford-cs25-transformers.srt" \
--folder "Education/CS25" \
--title "Transformers United - Introduction" \
--tags "stanford" "transformers" "deep-learning"处理会议谈话
# Conference presentation
python3 run_srt_agent.py \
"neurips-2023-attention.srt" \
--folder "Conferences/NeurIPS2023" \
--tags "neurips" "attention" "research"批处理
# Process entire course
python3 srt_to_obsidian_agent.py \
--batch "/path/to/cs25/subtitles/" \
--folder "Education/CS25/Transcripts" \
--tags "stanford" "cs25" "education"高级功能
自定义格式
您可以扩展 TranscriptFormatter 类以添加自定义格式:
class CustomTranscriptFormatter(TranscriptFormatter):
def format_transcript(self, paragraphs, title):
# Add custom formatting logic
content = super().format_transcript(paragraphs, title)
# Add table of contents, summary, etc.
return content与其他工具集成
该代理可以与其他工具集成:
- YouTube下载器:处理下载视频中的字幕
- 视频处理管道:批量处理教育内容
- 记笔记工作流程:与现有的黑曜石工作流集成
贡献
要扩展代理:
- 添加新解析器:支持其他字幕格式(VTT、ASS等)
- 增强格式:添加更复杂的文本处理
- 改进分类:更好的自动标记算法
- 添加集成:支持其他笔记应用程序
许可证
这个项目是开源的。请根据您的需求自由修改和分发。
支持
对于问题或疑问:
- 检查故障排除部分
- 与一起跑步
--verbose详细输出 - 验证您的黑曜石保险库配置
- 确保MCP服务器设置正确
______________________________________________________________________
记笔记快乐! 📝✨
