Skip to content

kcuber118/nghkh_a2t

Repository files navigation

nghkh-a2t

Ứng dụng Electron để transcribe video thành file subtitle SRT, sử dụng AI model Qwen3-ASR.

Tính năng

  • Chọn file video (MP4, AVI, MKV, MOV, WebM, FLV, WMV)
  • Tự động trích xuất audio từ video
  • Transcribe audio sử dụng Qwen3-ASR-0.6B + ForcedAligner-0.6B
  • Xuất file subtitle SRT với timestamps chính xác
  • Hỗ trợ GPU (CUDA) và CPU fallback

Yêu cầu hệ thống

  • Node.js 18+
  • Python 3.10+ (cho development mode)
  • GPU (tùy chọn, để tăng tốc transcription):
    • NVIDIA GPU: CUDA 12.0+
    • AMD GPU: ROCm 6.0+ (Radeon RX 7000 series hoặc mớier)
    • CPU fallback luôn available

Cài đặt

Development Mode

# Clone repository
git clone <repo-url>
cd nghkh-a2t

# Cài đặt Node.js dependencies
npm install

# Tạo virtual environment Python
python3 -m venv .venv
source .venv/bin/activate  # Linux/macOS
# hoặc .venv\Scripts\activate  # Windows

# Cài đặt PyTorch (chọn 1 trong 3 options)

# Option 1: NVIDIA GPU (CUDA)
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124

# Option 2: AMD GPU (ROCm) - Linux only
pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm7.2

# Option 3: CPU only
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu

# Cài đặt Python dependencies
pip install -r python/requirements.txt

# Chạy ứng dụng
npm start

Build Production

# Build Python executables (PyInstaller)
npm run build-python

# Package Electron app
npm run package

# Tạo installer
npm run make

Cấu trúc dự án

nghkh-a2t/
├── src/
│   ├── main.ts          # Electron main process
│   ├── preload.ts       # Preload script cho IPC
│   ├── renderer.ts      # Renderer process (UI logic)
│   ├── srt.ts           # SRT formatter
│   └── electron-api.d.ts # TypeScript declarations
├── python/
│   ├── extract_audio.py  # Trích xuất audio từ video
│   ├── transcribe.py     # Transcribe audio dùng Qwen3-ASR
│   └── tests/            # Pytest test suite
├── scripts/
│   └── build-python/     # PyInstaller build scripts
├── forge.config.ts       # Electron Forge config
└── package.json

Cách sử dụng

  1. Mở ứng dụng
  2. Click nút Select Video để chọn file video
  3. Đợi quá trình trích xuất audio và transcription hoàn tất
  4. Xem kết quả transcription với timestamps
  5. Click Save SRT để lưu file subtitle

Architecture

IPC Channels

Channel Direction Description
dialog:openVideo Renderer → Main Mở file picker dialog
audio:extract Renderer → Main Trích xuất audio từ video
audio:transcribe Renderer → Main Transcribe audio
transcribe:progress Main → Renderer Progress updates
srt:save Renderer → Main Lưu SRT file

Python Subprocess Protocol

Python scripts communicate via JSON over stdout:

extract_audio.py

// Input: video path as CLI argument
// Output (stdout):
{"success": true, "audioPath": "/tmp/.../audio.wav"}
// hoặc
{"success": false, "error": "Error message"}

transcribe.py

// Input: audio path as CLI argument
// Output (stdout):
{"success": true, "language": "en", "segments": [{"text": "...", "start": 0.0, "end": 1.0}]}
// Progress (stderr):
{"type": "progress", "stage": "loading_model", "message": "Loading ASR model..."}

Testing

# Chạy Python tests với coverage
npm run test:python

# Hoặc trực tiếp
.venv/bin/python -m pytest python/tests/ -v --cov=python --cov-report=term-missing

Platform Support

Platform Package Format
Windows Squirrel installer (.exe)
macOS DMG, ZIP
Linux DEB, RPM

Known Issues

  • CUDA Driver: Nếu CUDA driver quá cũ, app sẽ tự động fallback về CPU mode
  • Large Models: Qwen3-ASR model được download lần đầu (~1.2GB), cần kết nối internet
  • Memory: Transcribe process cần ~4GB RAM minimum

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors