Generate subtitles (SRT/TXT) from video using OpenAI Whisper.
Project description
Subwhisperer – Generate subtitles from any video using OpenAI Whisper
Subwhisperer extracts audio from a video, transcribes it with OpenAI Whisper and generates SRT subtitles plus a plain‑text transcript.
✨ Features
- Audio extraction – pulls the audio track out of any video that FFmpeg can decode.
- Speech recognition – runs Whisper large locally (GPU or CPU) with word‑level timestamps.
- Smart chunking – splits long videos on silence then merges chunks so that every subtitle line is comfortably readable.
- Multiple outputs –
*.srt,*.txt, per‑segment JSON files.
📋 Requirements
- Python 3.10+
- FFmpeg & FFprobe – install via your package manager (
sudo apt install ffmpeg) or ffbinaries. - Torch + CUDA (optional) – if you have an NVIDIA GPU you’ll want the GPU wheels (see below).
🚀 Installation
Dev instalation:
# 1 Clone the repo (only if you want to run from source)
git clone https://github.com/Smarandii/subwhisperer.git
cd subwhisperer
# 2 Install the Python requirements
# – GPU users: match the cuXXX part to your CUDA version
pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu126
pip install -r requirements.txt
# – CPU‑only users can skip the first line and simply run:
# pip install -r requirements.txt
# 3 (Dev mode) Install the package into your environment
pip install -e .
Regular user installation:
GPU users
pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu126
pip install subwhisperer
CPU users
pip install subwhisperer
🔧 Usage
From anywhere:
subwhisperer /path/to/video.mp4 \
--output_dir outputs/ # optional
--audio_file custom/audio.mp3 # optional
--subtitle_file custom/subs.srt # optional
--transcription_file out.txt # optional
You can also invoke it directly:
python -m subwhisperer.cli /path/to/video.mp4
The command will:
- Extract
/output_dir/video.mp3(or reuse it if it already exists) - Split it on silence > 5 s (configurable inside
AudioExtractor) - Transcribe each chunk with Whisper
- Merge the chunks and write
video.srt– ready for any player/editorvideo.txt– the plain transcript*_chunks.json– raw Whisper output before/after merging
🗂️ Project layout (important bits)
subwhisperer/
├─ src/
│ └─ subwhisperer/
│ ├─ cli.py # entry‑point / argument parsing
│ └─ core/ # building blocks
│ ├─ audio_extractor.py
│ ├─ whisper_transcriber.py
│ ├─ text_merger.py
│ └─ ...
└─ tests/
└─ test_process_video.py # quick smoke test
🆘 Troubleshooting
- CUDA not detected – make sure you installed the matching Torch wheel and
that
nvidia-smishows your GPU. - Subtitles out of sync – adjust
max_length,thresholdor the silence parameters inTextMerger/AudioExtractor. - Whisper is slow on CPU – try
--device cuda(automatic if CUDA is available) or down‑grade to a smaller Whisper model.
🤝 Contributing
Pull requests and feature ideas are welcome. Please open an issue first if you plan a large change.
📄 License
MIT © Smarandii 2024–present
🙏 Special thanks
Huge thanks to @arturtur for the After Effects script that imports SRT files – bundled here as Import SRT into Adobe After Effects.jsx.
This tool was developed as personal tool for creating fast subtitles and importing them to AE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file subwhisperer-1.1.0.tar.gz.
File metadata
- Download URL: subwhisperer-1.1.0.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64bd0d37c9578d6091ae5ffe33a0ccc06cbacd626edbc6959beb8552da5a1eca
|
|
| MD5 |
89a3160746ee3f16f5e2fe3af6e20524
|
|
| BLAKE2b-256 |
b0e5c37789a683d194f8c7709cf97ced326e5f52ceaaf929df27277a196eddf8
|
File details
Details for the file subwhisperer-1.1.0-py3-none-any.whl.
File metadata
- Download URL: subwhisperer-1.1.0-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cda78614a2e77a04460a334fb50d2326beab262dd91cdbf720a7e3399b41b959
|
|
| MD5 |
03d000d9de8c1e1a6b2966b36fe25d18
|
|
| BLAKE2b-256 |
3d62aa95931bf2188cf356dab21b06ff9a6dbaa8a9472443e087be875550b4e5
|