DEV Community

ixilig
ixilig

Posted on

Offline subtitle generator with local Whisper (no API fees)

Per-minute subtitle APIs add up, and they mean uploading your video to someone else's server. I wanted a small tool that makes an .srt file entirely on my own machine, so I wrapped faster-whisper in a short Python script.

How it works

  1. faster-whisper transcribes the audio locally (the model is downloaded once, then it works offline).
  2. The script writes the segments out as a standard SRT file.
  3. Optionally, ffmpeg burns the subtitles into a copy of the video.

Usage

pip install -r requirements.txt
python autosub.py video.mp4 --lang en --model small
python autosub.py video.mp4 --burn
Enter fullscreen mode Exit fullscreen mode

A real run

I ran it on a short synthetic English speech clip (3 sentences) with the tiny model. Actual output of v1.1:

1
00:00:00,000 --> 00:00:04,560
Welcome everyone. Today I will show you
something absolutely incredible that

2
00:00:04,560 --> 00:00:05,520
nobody expected.

3
00:00:06,400 --> 00:00:10,692
This is the craziest moment of the entire
stream. I cannot believe this just

4
00:00:10,692 --> 00:00:11,200
happened.

5
00:00:12,080 --> 00:00:15,920
Thank you all for watching and see you
tomorrow.
Enter fullscreen mode Exit fullscreen mode

A bug I almost shipped

My first version passed its own test, but when I read the output line by line, words were missing: "nobody expected." and "happened." had vanished. The wrapping function kept only the first two lines of any long segment and silently dropped the rest. Version 1.1 splits long segments into several cues instead (max two lines each) and shares the time between them. The package now includes a small offline test that checks that every word survives. Lesson: "the test passed" is not the same as "I read the output".

Honest notes

  • Tested on English with the tiny and small models, SRT output and --burn. Other languages use the same engine, but I have not tested them all.
  • Cue timing inside a split segment is proportional to text length, so it is an approximation.
  • On CPU, expect roughly real-time speed or slower with the small model.
  • I am a student developer and this was built together with Claude (an AI assistant); I ran and checked the code myself.

Get it

The packaged version (script, README, requirements, test) is on Gumroad for $9: https://ixilig.gumroad.com/l/glopkp

Feedback and bug reports are welcome.

Top comments (0)