This project provides a tool for automatically generating subtitles for videos, supporting both transcription and translation into multiple languages using Whisper and Helsinki-NLP MarianMT models.
- Extracts audio from video files.
- Detects the language of the audio and transcribes it into subtitles.
- Optionally translates the subtitles to another language (English <-> French).
- Generates SRT subtitle files.
- Python 3.11+
whisper
(OpenAI's Whisper model)torch
(PyTorch)moviepy
(For video and audio processing)transformers
(For translation models)
-
Clone the repository:
git clone https://github.com/ekomlenovic/AI-W-Subtitles.git cd AI-W-Subtitles
-
Install the required packages with pip or conda:
pip install -r requirements.txt
or
conda env create -f environment.yml conda activate subtitles
The script can be run from the command line using the following syntax:
python main.py --translate <fr/en> ./path/to/video.<mp4/mkv/avi>
--model_name
: (Optional) The Whisper model to use. Default is turbo. Available options:tiny
,base
,small
,medium
,large
,turbo
. Choose the model.--translate
: (Optional) The language to translate the subtitles to. Options:fr
,en
(French, English).
The generated subtitle files will be saved in a folder named subtitles
, containing:
- Original subtitles in the detected language (e.g.,
video_fr.srt
). - Translated subtitles in the specified language (e.g.,
video_en.srt
), if translation is requested.
Building the documentation website.
mkdocs build
The documentation website is generated with MkDocs and is available in the site
folder. To view the documentation, open the index.html
file in your browser.
Feel free to fork the repository, open issues, and submit pull requests. Contributions are always welcome!