Skip to main content

Video transcription and translation tool using Whisper and Gemini

Project description

Nakplae

A simple, elegant tool for transcribing videos to SRT subtitles and translating them with minimal dependencies.

Features

  • Transcribe video files to SRT subtitles using Whisper locally (multiple model options)
  • Support for multilingual content using language-agnostic models (tiny, base, small, medium, large)
  • Faster English-specific models available (tiny.en, base.en, small.en, medium.en)
  • Optimized for speed with multi-threading and reduced beam size
  • Translate SRT subtitles using Google's Gemini 2.0 Flash model
  • Supports translation to any language (defaults to Thai)
  • GPU acceleration for faster transcription (CUDA and Apple Silicon MPS support)
  • Real-time Whisper progress output for better visibility
  • Simple command-line interface
  • Minimal dependencies

Installation

Setup Environment

  1. Create a virtual environment:

    python -m venv .venv
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
    
  2. Install the package:

    # Installation from PyPI (includes GPU support by default)
    pip install nakplae
    

    For developers:

    # Clone the repository
    git clone https://github.com/elimydlarz/nakplae.git
    cd nakplae
    
    # Install in development mode
    pip install -e ".[dev]"
    

Prerequisites

  1. Ensure you have FFmpeg installed (required by Whisper)

    • On macOS: brew install ffmpeg
    • On Ubuntu: sudo apt install ffmpeg
    • On Windows: Download from the official website or use chocolatey
  2. For local LLM translation (optional):

    • Install llama.cpp and ensure llama is in your PATH
  3. For Gemini translation:

    • Set GEMINI_API_KEY environment variable with your API key:
      export GEMINI_API_KEY=your_api_key_here
      
    • Uses the Gemini 2.0 Flash model for translations

Usage

After installation, you can use the nakplae command directly:

# Basic usage (translates to Thai by default)
nakplae video_file.mp4

# Translate to a different language
nakplae video_file.mp4 --lang "Spanish"

# Only transcribe, don't translate
nakplae video_file.mp4 --transcribe-only

# Specify output directory
nakplae video_file.mp4 --lang "French" --output /path/to/output

# Use a faster model for multilingual content
nakplae video_file.mp4 --model tiny

# Use English-specific model for faster English transcription
nakplae video_file.mp4 --model small.en 

# Use a more accurate model for important content
nakplae video_file.mp4 --model medium

If you installed in development mode, you can also run:

python -m nakplae video_file.mp4 --lang "Spanish"

The program will automatically use GPU acceleration if available (CUDA on NVIDIA GPUs or MPS on Apple Silicon).

Development

# Run tests
pytest

# Format code
black .

# Run linter
ruff check .

# Run type checker
mypy nakplae

Publishing

To publish a new release to PyPI:

# 1. Update version in pyproject.toml

# 2. Build the package
python -m build

# 3. Upload to PyPI (requires API token)
python -m twine upload dist/*X.Y.Z* -u __token__ -p $PYPI_API_TOKEN

Project Structure

nakplae/
├── nakplae/
│   ├── __init__.py
│   ├── __main__.py
│   ├── transcribe.py
│   └── translate.py
├── tests/
├── pyproject.toml
├── requirements.txt
└── requirements-dev.txt

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nakplae-0.8.0.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nakplae-0.8.0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file nakplae-0.8.0.tar.gz.

File metadata

  • Download URL: nakplae-0.8.0.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for nakplae-0.8.0.tar.gz
Algorithm Hash digest
SHA256 51a94d12a9e5b8f5ca422f6a0253db27dbfa186a768ceb587df8cf64904cdaf5
MD5 8c207f2788ad32f6bcb520e99cf4ecbe
BLAKE2b-256 c8198f6f68d6de876d70cb944c1277f5fe422bb9958e93525afaa4793885c133

See more details on using hashes here.

File details

Details for the file nakplae-0.8.0-py3-none-any.whl.

File metadata

  • Download URL: nakplae-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for nakplae-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 045fe31acf14e9ca58d5f2071d94e33e9a4a5767ce716e3adebe53fd478eca8a
MD5 367fe4422d59bb8dfe2d54cf05bdf6cc
BLAKE2b-256 f5e059a9a31d06d60d9b304cd805eb9f1d911101d529b22c1001acea2aac7269

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page