import gradio as gr from tqdm import tqdm from transformers import pipeline from IPython.display import YouTubeVideo from youtube_transcript_api import YouTubeTranscriptApi def video2Summarizer(link): youtube_video = link video_id = youtube_video.split('=')[1] transcript = YouTubeTranscriptApi.get_transcript(video_id) result = "" for i in transcript: result += ' ' + i['text'] summarizer = pipeline('summarization') num_iters = int(len(result)/1000) summarized_text = [] for i in tqdm(range(0, num_iters + 1)): start = 0 start = i * 1000 end = (i + 1) * 1000 out = summarizer(result[start:end]) out = out[0] out = out['summary_text'] summarized_text.append(out) return summarized_text iface = gr.Interface(fn = video2Summarizer, inputs = 'text', outputs = gr.outputs.Textbox(label = "Summarized output"), title = 'Video To Text Summarizer', description = 'Just give the url of the YouTube video, then the app will give you the summarized format of the video in 5 to 10 Min, its based on the video length what you have given. Use this example and try to run the same example by clicking that', examples = [['https://www.youtube.com/watch?v=kEN2Omq9mwk']] ) iface.launch(inline = False)