This article explains how to generate YouTube SRT subtitle files using AI, specifically WhisperX. The process is straightforward and can be done using Google Colab.
Accessing the Required Resources
To begin, navigate to the provided GitHub link (found in the YouTube description of the video). From there, click the "Open in Colab" link to open the notebook in a new tab.
Preparing the Colab Notebook
Inputting Your YouTube Video URL
Locate the YouTube video for which you want to create subtitles. Copy the video's link address. In the Colab notebook, find the section where you need to specify the video URL and paste the copied link.
Setting the Language
Adjust the language setting in the Colab notebook to match the language spoken in your YouTube video. For English videos, set it to "EN." For Indonesian videos, as demonstrated in the transcript, set it to "ID."
Running the Colab Notebook
Once the URL and language are set, click "Runtime" and then "Run All." Confirm by clicking "Run Anyway." The program will then begin its process automatically.
The Subtitle Generation Process
- Downloading the MP3: The program first downloads the audio from your YouTube video in MP3 format.
- Transcribing with AI: It then uses the WhisperX AI model to transcribe the audio and generate the subtitle (SRT) file.
- Downloading the SRT File: Once complete, the SRT file (named "audio.srt") will be available for download.
Downloading and Reviewing the SRT File
After the program finishes, an "audio.srt" file will be generated. Double-click the file to review the generated subtitles. To download the file, click the three dots next to the filename and select "Download."
Uploading the SRT File to YouTube
- Edit Your Video: Go to your YouTube Studio and edit the video for which you generated the subtitles.
- Navigate to Subtitles: In the video editor, go to the "Subtitles" section.
- Add Language: Add the language of the subtitle (e.g., Indonesian).
- Upload File: Click "Add Subtitle" and choose "Upload file." Select the SRT file you downloaded from Google Colab.
- Publish: Once the subtitles are uploaded and synced, publish the changes to your video.
Adding Subtitles in Other Languages (Auto-Translation)
You can also add subtitles in other languages. For example, to add English subtitles to an Indonesian video:
- Add Language: Add English as a language in the "Subtitles" section.
- Auto-Translate: Select the "Auto-translate" option. This will translate the existing Indonesian subtitles into English.
- Review and Publish: Review the auto-translated subtitles and publish the changes.
Processing Time
The time it takes to generate the subtitles depends on the length of your video. In the example provided, a 5-minute video took approximately 4 minutes to generate the SRT file. This includes the time to download the mp3, download the AI model and to translate the audio.