Spaces:
Runtime error
Runtime error
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() |