电影音频转录工具
一种用于从电影中提取音频并将其转录为markdown文件的模块化系统。
特性
- 音频提取:从各种视频格式(MP4、AVI、MOV等)中提取音频
- 直接音频处理:直接处理音频文件(WAV、MP3、FLAC、M4A等)
- YouTube集成:下载YouTube视频并提取字幕
- 字幕转换:将SRT/VTT字幕转换为markdown格式
- 转录:使用高级语音识别将语音转换为文本
- Markdown输出:生成带有时间戳的格式良好的markdown文件
- 模块化设计:每个组件处理特定的职责
- 错误处理:全面的错误处理和信息反馈
- 批处理:高效处理多个文件
- 自动格式检测:自动检测视频和音频文件
MCP服务器(基于路径的转录)
A. Python MCP服务器 为AI助手公开按路径转录(单运行时,无子进程):
transcribe_file:音频/视频文件的路径→ 创建一个markdown转录(运行现有的Python管道)。read_transcription:转录文件的路径→ 返回其内容(以便LLM可以通读成绩单)。get_supported_formats:返回支持的格式和选项。
看 docs/MCP_SERVER.md 用于设置、工具和Cursor/MCP客户端配置。
pip install -r requirements.txt
python mcp_server.py # Start MCP server (stdio)项目结构
transcribe/
├── mcp_server.py # MCP server (Python, FastMCP, stdio)
├── main.py # CLI entry point
├── requirements.txt # Python dependencies (includes mcp)
├── setup.py # Package setup
├── scripts/
│ └── init_project.sh # One-time setup (venv, pip install)
├── transcribe/ # Python package
│ ├── core/ # Core interfaces, types, and pipeline
│ ├── extractors/ # Audio extraction modules
│ ├── transcribers/ # Speech-to-text modules
│ ├── formatters/ # Output formatting modules
│ ├── utils/ # Utility functions
│ ├── cli/ # Command line interface
│ └── config.json # Default configuration
├── tests/ # Test files
├── docs/ # Documentation
├── examples/ # Example scripts
├── input/ # Input audio/video (optional)
├── output/ # Generated transcripts (optional)
└── downloads/ # Downloaded media (optional)安装
先决条件
- Python 3.8+ -确保你安装了Python
- FFmpeg -音频提取所需
快速设置
macOS/Linux:
# Make the script executable
chmod +x scripts/init_project.sh
# Run the initialization script (from repo root)
./scripts/init_project.sh窗户: 创建一个venv并手动安装:
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt手动设置
- 创建虚拟环境:
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate.bat- 安装依赖项:
pip install -r requirements.txt- 安装FFmpeg:
# macOS
brew install ffmpeg
# Ubuntu/Debian
sudo apt-get install ffmpeg
# Windows
# Download from https://ffmpeg.org/download.html- 验证安装:
python main.py --help用法
基本用法
from transcribe import TranscribePipeline
# Create pipeline
pipeline = TranscribePipeline()
# Process a single file
result = pipeline.process("path/to/movie.mp4", "output.md")
# Process multiple files
results = pipeline.process_batch([
"movie1.mp4",
"movie2.avi"
], "output_directory/")命令行界面
# Transcribe a video file
python main.py --input movie.mp4 --output transcript.md
# Transcribe an audio file
python main.py --input recording.wav --output transcript.md
# Process multiple files (video and audio)
python main.py --input-dir ./recordings/ --output-dir ./transcripts/
# With custom settings
python main.py --input recording.mp3 --output transcript.md --language en --model largeYouTube视频下载器
# Download YouTube video with subtitles
python examples/youtube_downloader.py "https://www.youtube.com/watch?v=VIDEO_ID"
# Download with subtitle conversion to markdown
python examples/youtube_downloader.py "https://www.youtube.com/watch?v=VIDEO_ID" --convert-to-markdown
# Download and transcribe with Whisper
python examples/youtube_downloader.py "https://www.youtube.com/watch?v=VIDEO_ID" --transcribe
# Download subtitles only
python examples/youtube_downloader.py "https://www.youtube.com/watch?v=VIDEO_ID" --subtitles-only配置
该系统采用模块化配置方法:
- 音频提取:可配置的质量、格式和块大小
- 转录:多个语音识别引擎(Whisper、谷歌语音等)
- 输出格式:可自定义的标记模板和格式选项
建筑
该项目遵循模块化设计,关注点明确分离:
- 文档接口:所有数据都以一致的文档格式流动
- 模块化组件:每个工具处理一个特定的职责
- 错误处理:全面的错误处理和信息反馈
- 状态管理:跟踪处理背景和进度
- 灵活内存:支持短期和长期存储
贡献
- 遵循模块化架构原则
- 实施适当的错误处理
- 添加综合测试
- 更新文档
许可证
MIT许可证
