Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
722 changes: 607 additions & 115 deletions audio_processor.py

Large diffs are not rendered by default.

569 changes: 569 additions & 0 deletions dependency_checker.py

Large diffs are not rendered by default.

599 changes: 599 additions & 0 deletions language_detector.py

Large diffs are not rendered by default.

793 changes: 708 additions & 85 deletions main.py

Large diffs are not rendered by default.

133 changes: 121 additions & 12 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,134 @@
# VideoSubtitleAI - 本地离线音视频转字幕工具
# 依赖包列表
#
# ⚠️ 重要提示:在安装这些包之前,请先安装 FFmpeg
# Windows: winget install Gyan.FFmpeg
# macOS: brew install ffmpeg
# Linux: sudo apt install ffmpeg
#
# 快速安装所有依赖:
# pip install -r requirements.txt
#

# ============================================================================
# 必需依赖(必须安装)
# ============================================================================

# 核心依赖
# OpenAI Whisper - 核心语音识别模型
openai-whisper>=20231117

# PyTorch (Whisper需要,根据系统环境选择合适版本)
# 安装GPU版本 (推荐,速度快):
# pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
# PyTorch - Whisper 依赖的深度学习框架
# ⚠️ 强烈建议安装 CUDA 版本以获得 GPU 加速
#
# 安装 GPU 版本 (推荐,速度提升 10-100 倍):
# pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
#
# 或者安装CPU版本:
# pip3 install torch torchvision torchaudio
# 或者安装 CUDA 12.1 版本:
# pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
#
# 注意: 以下仅为最小依赖,实际安装时请根据需求安装完整版PyTorch
# 安装 CPU 版本 (速度较慢):
# pip3 install torch torchvision torchaudio
#
# 注意: 以下仅为最小依赖,实际使用时请安装完整版
torch>=2.0.0

# 音频处理 (可选,FFmpeg通常需要单独安装)
# ffmpeg-python>=0.2.0
# pydub>=0.25.1
# NumPy - 数值计算库
numpy>=1.24.0

# ============================================================================
# 可选依赖(推荐安装)
# ============================================================================

# 进度条显示
tqdm>=4.66.0

# 其他工具
numpy>=1.24.0
# 颜色输出(用于更友好的终端显示)
colorama>=0.4.6

# 版本比较(用于依赖检查)
packaging>=23.0

# ============================================================================
# 双语字幕翻译功能可选依赖
# ============================================================================

# 在线翻译API支持
# requests>=2.28.0 # 用于百度/Google/DeepL翻译API

# 本地翻译模型(Helsinki-NLP OPUS-MT)
# transformers>=4.30.0
# sentencepiece>=0.1.99
# torch>=2.0.0 # 已在必需依赖中

# ============================================================================
# 增强功能说明
# ============================================================================
#
# 新增功能模块:
# 1. subtitle_models.py - 统一数据模型(字幕段、样式、文档)
# 2. subtitle_translator.py - 翻译模块(支持多后端)
# 3. subtitle_editor.py - 字幕编辑(撤销/重做、时间轴调整)
# 4. subtitle_exporter.py - 多格式导出(SRT/ASS/VTT)
# 5. subtitle_embedder.py - 字幕硬嵌入(FFmpeg烧录)
# 6. language_detector.py - 语言检测优化(多语言混合)
# 7. video_subtitle_enhanced.py - 增强版主模块
#
# 使用示例:
# - 生成双语字幕:python main.py -i video.mp4 --bilingual
# - 导出多种格式:python main.py -i video.mp4 --formats srt,ass,vtt
# - 字幕硬嵌入:python main.py -i video.mp4 --embed-video
# - 自定义样式:python main.py -i video.mp4 --style yellow --font-size 48
# - 仅导出模式:python main.py --export-only -s existing.srt --formats ass
#

# ============================================================================
# 系统工具(必须单独安装)
# ============================================================================
#
# FFmpeg - 音视频处理工具(必需)
#
# Windows:
# 方法1: 使用 winget (推荐)
# winget install Gyan.FFmpeg
#
# 方法2: 使用 Chocolatey
# choco install ffmpeg
#
# 方法3: 手动安装
# 1. 访问 https://www.gyan.dev/ffmpeg/builds/
# 2. 下载 ffmpeg-release-full.7z
# 3. 解压到 C:\ffmpeg
# 4. 将 C:\ffmpeg\bin 添加到系统 PATH
# 5. 重启命令行/IDE
#
# macOS:
# brew install ffmpeg
#
# Linux (Ubuntu/Debian):
# sudo apt update
# sudo apt install ffmpeg
#
# Linux (Fedora):
# sudo dnf install ffmpeg
#
# ============================================================================

# ============================================================================
# 安装步骤总结
# ============================================================================
#
# 1. 安装 FFmpeg (必需)
# Windows: winget install Gyan.FFmpeg
# macOS: brew install ffmpeg
# Linux: sudo apt install ffmpeg
#
# 2. 安装 PyTorch (推荐 GPU 版本)
# pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
#
# 3. 安装其他依赖
# pip install -r requirements.txt
#
# 4. 验证安装
# python main.py --check-deps
#
# ============================================================================
Loading