Generate subtitles (SRT/TXT) from video using OpenAI Whisper.
Project description
Video Subtitler with Whisper
This repository contains a Python application that extracts audio from a video file, transcribes it using OpenAI's Whisper model, and then generates subtitles in SRT format.
Features
- Audio Extraction: Extracts audio from a video file.
- Speech Recognition: Transcribes audio to text using OpenAI's Whisper model.
- Subtitle Generation: Converts transcribed text into SRT format.
Requirements
- Python 3.10
- FFmpeg && FFprobe - you can get both via https://github.com/ffbinaries/ffbinaries-node or
sudo apt install ffmpeg - Various Python libraries listed in
requirements.txt
Installation
-
Clone the repository:
git clone https://github.com/your-username/video-subtitler.git cd video-subtitler
-
Install the required Python libraries:
- if you have CUDA:
- Check your cuda version
nvidia-smi
+-----------------------------------------------------------------------------------------+ | NVIDIA-SMI 560.94 Driver Version: 560.94 CUDA Version: 12.6 | |-----------------------------------------+------------------------+----------------------+ | GPU Name Driver-Model | Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. | | | | MIG M. | |=========================================+========================+======================| | 0 NVIDIA GeForce RTX 3060 Ti WDDM | 00000000:07:00.0 On | N/A | | 0% 45C P8 26W / 200W | 888MiB / 8192MiB | 2% Default | | | | N/A | +-----------------------------------------+------------------------+----------------------+
- CUDA Version: 12.6, that means we need to use https://download.pytorch.org/whl/cu126. If your CUDA version is different, change digits after cu to match your version without any dots.
pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu126 pip install -r requirements.txt
- Check your cuda version
- If you don't have CUDA:
pip install -r requirements.txt
- if you have CUDA:
-
Make sure FFmpeg is installed on your system. Visit the FFmpeg download page for installation instructions.
Usage
-
To use the application, you need to pass the path to the video file as an argument. Optionally, you can specify the paths for the extracted audio and output subtitle file.
python vsub.py path_to_video.mp4 --audio_file path_to_audio.mp3 --subtitle_file path_to_subtitle.srt
For example:
python vsub.py video.mp4
This command will extract audio, transcribe it, and generate subtitles in the same directory as the video file.
Files Description
vsub.py: The main Python script that orchestrates the extraction, transcription, and subtitle generation.utils/: Contains helper classes for audio extraction, transcription, text merging, and more.requirements.txt: A list of Python libraries required to run the application.
Troubleshooting
If you encounter any issues with the transcription or subtitle generation:
- Ensure that your FFmpeg installation is up to date.
- Check that the paths and filenames in the scripts are correct.
- Verify that the audio and video files are not corrupted and are in a format supported by FFmpeg.
Contributing
Contributions to this project are welcome. Please fork the repository, make your changes, and submit a pull request.
License
This project is open-sourced under the MIT License. See the LICENSE file for more details.
Special thanks!
Thanks @arturtur for script that imports srt file into Adobe After Effects project. Link to the script: Messing with After Effects and Subtitles
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.0.0.tar.gz.
File metadata
- Download URL: subwhisperer-1.0.0.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24b00c60371796a76eec13bf8e32ffd408f38780c694af5a2591b60315b36e72
|
|
| MD5 |
ec0a345b81caab09afa291159aab8f5c
|
|
| BLAKE2b-256 |
2960c1791ec181dd4d63588b60fd0824723bac9cca931894a8efd7d76433eb0c
|
File details
Details for the file subwhisperer-1.0.0-py3-none-any.whl.
File metadata
- Download URL: subwhisperer-1.0.0-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d9d62c313fd1f68f78514ae43f9f60a6d24371f847de262d4087b79310a0a99
|
|
| MD5 |
02f8a9f71d54711df555c4952f4e7c0d
|
|
| BLAKE2b-256 |
ccb65be2be52c99d86010bbbc8c88a53797b0f85fb17ab8d8f3a484ef9e74363
|