Easily Transcribe Youtube Videos with OpenAI Whisper
In this tutorial, we will see how to easily transcribe Youtube Videos with OpenAI Whisper.
If you are new to OpenAI Whisper, check out this getting started guide.
Table of Contents
Transcribe Youtube Videos with OpenAI Whisper
Requirements
- A Mac, Linux, or Windows Computer
- Python 3.x or higher installed
- A little knowledge of command line and how to type in and run python code.
If you are for something less technical way to transcribe youtube videos with OpenAI Whisper, check out this GUI Browser-based Application from HuggingFace.
But if you still want to do this locally on your own computer, continue reading.
Setup
We need to first Install whisper and pytube modules. You can do that by running below commands in your command line program.
pip install git+https://github.com/openai/whisper.git
pip install pytube
Now open your code editor and create a new python file and add the below code.
# first we import whisper and pytube modules
import whisper
from pytube import YouTube
# load base model. for other models, see this post – harishgarg.com/writing/openai-whisper-getti..
model = whisper.load_model(“base”)
# download the youtube video in the link below. change it to the video link you are trying to transcribe
link = ‘youtube.com/shorts/mBfXB6aTJgY’
yt = YouTube(link)
path = yt.streams.filter(only_audio=True)[0].download(filename=”audio.mp4″)
options = whisper.DecodingOptions(without_timestamps=True)
# transcribe the downloaded youtube video using whisper
results = model.transcribe(path)
# print the resulting transcription print(results["text"])
Running the Whisper python code
Save the python file and execute it from the command line program
You will see the transcribed text displayed on the screen.
Next, change the video link in the above code to one of the youtube videos you want to transcribe, save the python file and run it again.
Here is the whole code running inside a Google Colab Notebook that you can run yourself in a browser.