Skip to content

Create a Q&A Bot for Youtube Videos

Goals

  • Understanding the building blocks of working with Multimodal AI projects
  • Working with some of the fundamental concepts of Langchain
  • How to use the Whisper API to transcribe audio to text
  • How to combine both Langchain and Whisper API to create ask questions of any Youtube video

Before you begin

You'll need a developer account with OpenAI and a create API Key

Task 0: Setup

 !pip install --force-reinstall https://github.com/yt-dlp/yt-dlp/archive/master.tar.gz
!pip install langchain
#Importing the Required Packaces including: "os" "openai" "yt_dlp as youtube_dl" and "from yt_dl import Download Error"

import os 
import openai
import yt_dlp as youtube_dl
from yt_dlp import DownloadError
import os

openai_api_key = os.getenv("OPENAI_API_KEY")
print(os.getenv('OPENAI_API_KEY'))
# Importing the required libraries from Langchain 
from langchain.embeddings.openai import OpenAIEmbeddings   
from langchain.text_splitter import CharacterTextSplitter   
from langchain.vectorstores.faiss import FAISS   
from langchain.chains import RetrievalQAWithSourcesChain   
from langchain import OpenAI

For this project we need the os and the yt_dlp packages to download the YouTube video of your choosing, convert it to an .mp3 and save the file. We will also be using the openai package to make easy calls to the OpenAI models we will use.

Instructions

Import the following packages.

  • Import os
  • Import openai
  • Import yt_dlp with the alias youtube_dl
  • From the yt_dlp package, import DowloadError