hello all my name is crush naak and welcome to my YouTube channel so guys yet another amazing video here we are going to create an end to endend project using Google gini pro and the project name is uh related to YouTube videos transcriber now this is an amazing project our main aim will be that we will try to just give the video YouTube link YouTube video link and then it should be able to automatically extract all the text all the transcri text from that specific videos now before I go ahead uh and start implementing this I would like to give some important credits to dendra Verma so you can see that his post was there and here you can see like what all things he has specifically implemented and uh by seeing the tutorials right uh uh where I've created a lot of Germany project Google Germany projects He has specifically used this and he has actually created this so I asked for the link so that you know I could have have made a video for you all but again uh this entire project credit goes to uh dendra Verma and but I will try to implement it completely from scratch how you can actually do the setup each and everything as we go ahead okay so uh again dendra Verma thank you very much and again his LinkedIn will be provided in the description of this particular video you can go ahead and uh you know probably contact him ask him any questions if you have okay so uh let me quickly go ahead and start this specific project so here is this particular project so first of all as usual what we are going to do is that we going to go to the terminal and create our new environment okay so in order to create our new environment I will go ahead and write Honda so I don't want to do it in Powershell so let me just go back to command prompt and this is the first step that you specifically require uh and we have done this cond create P VNV and I'm going to specifically use Python 3. 10 right and I'll also give Dy so that it does not ask me any permissions with respect to the installation so till the environment is going and getting created what I'm actually going to do is that I'll go ahead and create some of the files uh like EnV I also require requirements. txt so and one more file we will try to create one is app.
py okay and we'll start writing our specific code with respect to this okay now what are libraries we specifically require and all as you'll know that we are going to use this uh Google G Pro over here right so let me do one thing first of all let me go ahead and create an environment variable so for that I will copy this API key from maker. google. com and I will go ahead and paste it over here right you can also do it completely it is for free Google provides you this for free for some number of request right so here I will write Google uncore API Google uncore aior key is equal to this specific environment variable okay I'm going to set this up as an environment variable I will close this I will go ahead and activate my V EnV environment now whatever uh libraries I really need to install it will be installed in in this specific environment itself right so the V EnV environment is created and we have activated it now the next thing that we have specifically going to do is that we will go ahead and use some of the libraries that we are going to use in this project one is YouTube transcript _ API why this YouTube _ transcript _ API is used let me just go ahead and show you so YouTube uncore transcript _ API so if you probably go ahead and see this is a python API which allows you to get the transcript of subtitles from a given YouTube video it also works for automatically generated subtitles supports translation of subtitles and it does not require a headless browser like celum based Solutions too okay so just by using this specific uh libraries we can probably uh you know extract all the transcript details that we have Okay so let's do one thing let's go ahead and install this I've already installed it anyhow right uh no I not installed it so I will go ahead and install it so YouTube transcript API will be required streamlet I'm to use as a front end Google generative AI python d.
v path okay so these all libraries we are going to install so let's quickly go ahead and write pip install minus r requirement. txt okay let me create the screen pip install minus r requirement. dxt so quickly let's see uh so it has not installed let me see okay it is not saved this file needs to be saved anyhow now let's go ahead and do the installation perfect so once it it gets installed we will start our coding in our app.
py5 okay and for coding also just understand that what all things we specifically require over here right so till this installation basically takes place uh till then I will go ahead and write the code import streamlet as St okay I'm going to use streamlet along with this I'm also going to import uh from EnV I'm going to import load uncore Dov specifically we require this for loading our API skis uh sorry environment variables and after this I will load. EnV okay so right now it is not giving us any suggestion because still the requirements uh the libraries are getting installed right so after sometime you'll be able to see that we'll also be able to see each and every suggestions from this okay so I've uh loaded this this this in short will load all the environment variables load all the environment variables okay so this is also done then import Google dot generative AI as geni done so this is also imported I'm going to specifically use this now you can see that this entire thing is loaded let me just go ahead and save it okay perfect this looks good from EnV load. EnV this is there this is there uh let me just have a look what is the [Music] error okay so from import google.
generative AI as a gen I've already done this I've also imported Streamlight EnV now from I'll also create a separate utility file let me do that in the later stage U now first thing after doing this is that I will go ahead and configure so I will write gen a do configure and inside this I will go ahead and write API key is equal to os. get EnV so I'm not imported OS also let me just go ahead and import it P OS okay os. get EnV and whatever is my environment variable I'm going to basically go to write that specific thing over here so I'll go to my EnV file call my Google API key and that is nothing but my API key over here let me close till there okay so once this is done we have configured the Gen AI now I'm going to create a function which is called as uh you know the fetch transcript something like this right so here I'm going to basically create a fetch transcript uh this will be responsible in fetching the transcript details you know from uh let's Okay let me just remove this right now let me do one thing let me go ahead and write this generate uncore Gore content okay so I'll first of all create this function okay and inside this what all things I really need to give so this generate Gemini content what it's going to do it is first of all going to take my transcript okay because at the end of the day I need to create a summary out of it so transcript will be the first thing this will not be this will be a text in short whatever text we are able to get from the YouTube video the second thing is that I can actually create a subject field like what this transcript is all about you know whether it is for data science or machine learning or physics so category wise we can specifically use it if you don't want to use this it's okay you can directly probably take this transcript and you can probably tell hey just provide me a summary right so uh let me do one thing let me remove this subject also I don't require this subject right now so what what I will do over here once I get the transcript you know I will go ahead and create a prompt or if you want I can also give the prompt over here itself right so let me just go ahead and give the prompt and let me create the prompt over here all right let's say here I will say uh you are a YT or YouTube video sumar ER summarizer you will you will be taking the transcript text transcript text and summarizing the entire video transcripts text okay let me use triple Cotes okay summarizing the entire video and providing the important summary summary in pointwise in points within within 200 or 250 words okay so I've given this simple prompt uh as soon as this prompt is given over here now what Google gin is basically going to do over here right uh we are going to probably just use this model dot gen dot gen AI dot generate sorry generate content right gen a DOT oh just a second first of all gen a do generative generative AI oh sorry generative model I'm going to use and call the model itself itself right so it will be nothing but gmin Pro right once I probably get this gini Pro now what I'm actually going to do is that I'll take this model which is responsible in working with text and then I'll specifically use this particular model and create our response so here I will go ahead and write model dot generate generate underscore content right and here I'm going to SP specifically use this prompt that I have along with this prompt I'm also going to give the transcript text I will combine this and probably give this transcript text now uh here you can probably see right I am giving this combination right prompt plus transcript text okay you are a YouTube video summarizer you'll be taking the uh taking the transcript text and summarizing the entire video and providing the important Su in points within uh 250 words the transcript text will be appended here okay something like this right and over here whatever transcript text we are specifically going to create you can include it over here itself right so here uh what we will uh you can also do is that you can create a prompt variable itself but right now let's go over here and keep it like this and let's see whether this is going to work or not okay but anyhow I'm going to give this entire prompt text itself okay so uh and I'm since I'm appending it over here that basically means it gets appended over here itself right so this I'm going to get the response and let me go ahead and write response do response.
text okay so I'm going to return the response. Text Now understand about this right this is when we are interacting with the Google gin pro model right but still our main method meth that we have right the most important method I'll say is to take out the transcript from the video right over here we are trying to do the summarization of those transcript right that we are getting from the YouTube video so for that what all libraries we will be using and what function I'll be creating so here I will go ahead and write from YouTube underscore transcript transcriptor API I'm going to import so I'm going to import this Library again from the transcript that I have actually downloaded now this YouTube transcript API will be responsible in getting from the video URL from the video URL uh it will try to get the ID of the video and then it will try to retrieve the entire transcript and remember all the videos needs to be public right if it is private it will not work so what we are going to do after this is is that we will create a function and this function is nothing but let me go ahead and create this function this function is definition extract transcriptor details okay so here we going to give my YouTube video URL okay so this is the input that I'm going to give now from this vtube video URL let me go ahead and write a TR catch block so that uh we handle the exception also so try pass and the next thing that I will be writing is nothing but accept uh and let me raise one exception exception as e and I can probably raise e okay so this is the exception that I'm going to probably raise now let's say I give the video URL first of all I need to get the video ID now in order to get the video ID if you probably see in the specific videos right like let's say this is my most popular video in in my channel this text that you see over here is the video ID So based on this video ID this YouTube API right whatever API we are specifically using it will be able to extract the entire transcript so I have to split from this URL this particular ID so how do we do that it is very simple a simple python code I will go ahead and write YouTube video URL do split now the main split should be happening with respect to this equal to right so I will go ahead and write equal to over here right now once we write equal to it is going to divide this into two terms zero index and first index so first index will basically have the ID itself so I will take the first index over here okay now this is done the next thing that I'm going to basically write is my transcript transcript text okay now this transcript text Will I will call this YouTube transcript API and then use do get transcript okay and here I'm going to basically give the video ID okay so this is the function that is sorry it should be getor transcript okay this is the function that we specifically use from this particular YouTube transcript API now once we get the transcript text what we can uh in short like this this transcript right now is in form of a list right it'll be having a lot of lists over there right one by one so what we will do one by one we will go ahead and append this together so that we form this as a paragraph so here you can see I have let me initialize this over here like this and let me do one thing okay so I'm saying from I in transcript text which is coming in the form of L list over here I will go ahead and append in this particular variable in the form of a paragraph okay I'm going to take all the text and append it over here and once we do this after doing this we can return this transcript okay so here we are going to return this transcript after this entire step is done now these are the two main functionalities this is probably exploring or I will write getting the transcript getting the transcript data from YT videos okay YT videos and then here getting the summary getting the summary based on prompt okay based on prompt from Google gini I hope everybody's very much clear with this right so these are the two main functionalities now the remaining part that is there is very simple you just need to create a streamlet app and probably Define all these things okay so what I'm actually going to do I will go ahead and create some stream L app over here so I will go ahead and write st. title okay so this will be my YouTube transcript to detail notes converter um I will create a text input box okay and this text input box will actually help me to get a YouTube link once I probably get the YouTube link so let's say if I get the YouTube link uh what we can actually do is that we can also display the thumbnail image right so what we going to do over here is that we will go ahead and split again with respect to the video ID okay so video ID I will just split it uh and take the first one I'll get the same video ID and then we can use st.
image to display the image itself right and this image URL is the default image uh URL that whenever you try to upload a image in YouTube in the form of thumbnail this is where it is stored and the reference over here is with respect to the video ID okay so this is how the entire URL is basically constructed so as soon as we uh provide the link over there okay and uh you can probably see that the image of that particular thumbnail of that video will be displayed in the bottom plan now I will also create a button okay and this button will be like uh get the detail description and all something like this okay so here we can go ahead and write one more function let's see so this is done so I'm saying if St do button if you're K clicking this get detailed notes then first thing what we really need to C is this nothing but extract transcript right so this function we will specifically call and here I'm going to give my YouTube link okay once we call this we are just going to get our entire transcript text right so here I'm going to transcript here I'm going to specifically get my transcript text okay now if this transcript rpt text if I get this transcript text then the next function that I have to call is nothing but generate gin content okay so here you'll be able to see generate G content this will be my summary and here I will give two important information one what all information I'll give one is the let me see one is the transcript text and next is the prompt so here I'm going to probably give my transcript text and the the second one is nothing but by prompt so the prompt variable is created over here and it is created over here um everything looks the transcript text will be appended over here uh please provide the summary of the text given here okay something like this I'm writing done generate gemin content I'll get the summary once I probably get the summary all I have have to do is that use markdown and write this code over here markdown and write and I will be getting the summary itself okay so this will basically be my summary so once this is done uh let's see whether everything will work fine or not uh I don't know let's see I'm not run it yet okay so let me just go ahead and write it over here now to run it I will go ahead and write streamlet run app.