This project is only available to Linux/MacOS users.
This project
-
uses openai/Whisper from OpenAI to generate video subtitles automatically.
-
adapted some codes from m1guelpf/auto-subtitle.
-
uses the base model from openai/Whisper. Which is multi-lingual and fairly fast. If you want to use a smaller model, you can change the model in
main.py
totiny
. However, the accuracy will be lower. -
has been tested on a youtube video of 8 min duration. It took around 2 min to generate the subtitles on my mac (CPU, Quad-Core Intel Core i5).
- Generate time-stamped subtitles for your video. Would be helpful in video editing.
- Add subtitles to lesson recordings to learn 3x faster by reading subtitles instead of listening. You might also navigate lectures via keywords.
- and more...
Dependency:
ffmpeg
: used to extract audio from videowhisper
: used to generate text from audiopip install whisper, ffmpeg # or pip3 install whisper, ffmpeg
It might take a while to install whisper
. Please be patient.
It's fairly simple, just copy and paste the following commands in your terminal.
-
Download the project
git clone https://github.com/madeyexz/whisper_subtitle.git
-
Run
main.py
, wherevideo_path
is the path to your video file and-LanguageCode
is where you choose the language of the subtitles.- Currently only
-en
and-zh
is available for English and Chinese subtitles respectively. However if you don't specify the language, it will choose language automatically. - If its your first project with
whisper
(especially withbase
model), it will take a while to download the model. Please be patient.
python3 main.py -LanguageCode video_path
e.g.
python3 main.py -en video.mp4
- Currently only
-
Collect the result. The result will be saved in the same directory as the video file and will be named as the video file name with
.srt
extension. -
Play the video with subtitles. You can use VLC or any other video player. Just put the
.srt
subtitle file in the same directory with the original video and play the video via the video player. Also, check if the subtitle file has the same name with the video.