File size: 2,086 Bytes
0903baf
 
abe4bb2
0903baf
aec378a
30f53c4
 
bf4e114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30f53c4
b2582f6
02de3fd
b2582f6
44be9a0
 
88d368f
abe4bb2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from transformers import pipeline
from youtube_transcript_api import YouTubeTranscriptApi
import gradio as gr


def summarize(Youtube_Video_Link):
  video_id = Youtube_Video_Link.split("=")[1]
  try:
    transcript = YouTubeTranscriptApi.get_transcript(video_id)
    summarizer = pipeline('summarization',model='sshleifer/distilbart-cnn-12-6')
    input_text = ""
    for i in transcript:
        input_text += ' ' + i['text']
    num_iters = int(len(input_text)/1000)
    summarized_text = []
    for i in range(0, num_iters + 1):
      start = 0
      start = i * 1000
      end = (i + 1) * 1000
      print("input text \n" + input_text[start:end])
      out = summarizer(input_text[start:end])
      out = out[0]
      out = out['summary_text']
      print("Summarized text\n"+out)
      summarized_text.append(out)
    output_text=' '.join(summarized_text)
    return output_text
  except:
    return "Some Error has occurred either with Video link passed is invalid or No Captions present for this video"

title = "YouTube Live 😎 Video Summarization"
examples = [("https://www.youtube.com/watch?v=zKvd1JwJ4Po"),("https://www.youtube.com/watch?v=9izcbNYmP8M"),]
text1 = (
    "<center> Deployed by: Owais Ahmad Data Scientist at <b> Thoucentric </b> <a href=\"https://www.linkedin.com/in/owaiskhan9654/\">Visit Profile</a> <br</center>""<center> Model Used : Meta/Facebook's <b>distilbart-cnn-12-6</b> Documentation href=\"https://huggingface.co/docs/transformers/model_doc/bart#bart/\">Link</a><br></center>" "<center> Kaggle Profile <a href=\"https://www.kaggle.com/owaiskhan9654\">Link</a> <br> </center>")
description = "Get YouTube Video Summarization. Just Enter the YouTube Video link below. Make sure Video has Captions and it is not very long as Model Computation time will Increase."
Youtube_Video_Link = gr.Textbox("Input YouTube Link here (Note: This will take time if passed a long video)", show_label=False)
App= gr.Interface(fn=summarize, inputs=Youtube_Video_Link, outputs="text", examples=examples,description=description, title=title,article=text1)
App.launch()