Generating Automated Subtitles with OpenAI’s Whisper on Ubuntu 22.04

computer and a laptop with editing software

I’ve used a MacOS app called MacWhisper for the past year to generate automated subtitles for my video content. MacWhisper uses OpenAI’s Whisper under the hood and exports the subtitles to .srt format. I then found ttconv, a command-line tool that allows me to convert the .srt format to the .ttml format WordPress.tv and YouTube prefer.

When I switched back to an Ubuntu workstation earlier this year, I lost the ability to use MacWhisper. Fortunately, the underlying tool is open source, so it was just a matter of installing it alongside ttconv. I soon realized that with both tools working from the command line, I could create a bash script to automate the entire process.

Software requirements

My first step was to install PIP, which I used to install Whisper and ttconv.

sudo apt install python3-pip
source ~/.profile

Next, I needed to install install Whisper.

This required making sure my nVidia drivers were updated and installing ffmpeg.

sudo apt install nvidia-driver-550 nvidia-cuda-toolkit
sudo apt install ffmpeg

Then I could install Whisper

pip install -U openai-whisper

And ttconv for the subtitle conversion

pip install --pre ttconv

I then created an autosubs script, which uses ffmpeg to extract the audio from the video file, uses whisper to create the .srt transcription, and uses ttconv to convert that to .ttml.

With autosubs installed in Ubuntu’s local binaries directory (/user/local/bin/) I can just run autosubs in a directory with mp4 files, and it will generate .ttml subtitle files for each video. I can also pass a single mp4 filename to generate a ttml subtitle for that file.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.