DEV Community

Cover image for Building an offline subtitle extractor with whisper.cpp and Electron
imper
imper

Posted on

Building an offline subtitle extractor with whisper.cpp and Electron

I watch a lot of foreign language content - anime, K-dramas, tech talks - and getting subtitles was always a pain. Upload to a random website, hit the daily limit, try another one, or install Python and figure out whisper's CLI.

So over the past few months I've been building a desktop app that handles the whole pipeline locally.

What it does

You drop a video file in, pick a whisper model size, and it spits out an SRT subtitle file. Optionally you can translate the subtitles using one of several engines.

The speech-to-text runs via whisper.cpp so everything stays on your machine. No uploads, no API calls for the transcription part. If you have an NVIDIA GPU it automatically uses CUDA, otherwise it falls back to CPU - this was one of the trickier parts to get right.

App Screenshot

Tech decisions

I went with Electron + Node.js because:

  • Cross-platform (though I'm mainly targeting Windows right now)
  • Easy to bundle whisper.cpp binaries and ffmpeg
  • The UI is just HTML/CSS/JS so iteration is fast

For whisper.cpp integration, the app spawns it as a child process with the right flags depending on whether CUDA is available. Model files (GGML format) auto-download on first run into a local _models/ folder.

Translation engines

Translation is optional. Currently supported:

  • MyMemory - free, no API key, ~50K chars/day
  • DeepL - free tier 500K chars/month, needs API key
  • OpenAI GPT - paid, good quality for nuanced translations
  • Gemini - Google's API, generous free tier

The app chunks subtitle text and sends it in batches to avoid rate limits. Each engine has its own quirks with language codes so there's a mapping layer.

v1.4.0 changes

Just pushed the latest update which adds:

  • Automatic GPU/CPU fallback detection
  • Bundled ffprobe-static (no more separate ffmpeg install)
  • Better DeepL language code mapping

Try it out

It's packaged as a portable .exe - no install needed, just extract and run.

GitHub: WhisperSubTranslate
License: GPL-3.0

If you're working on something similar or have suggestions, I'd love to hear about it.

Top comments (0)