Doubleupai commited on
Commit
51c2bdb
·
verified ·
1 Parent(s): c0d2b1b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from pytube import YouTube
3
+ from transformers import pipeline
4
+
5
+ # Initialize the pipeline for video summary generation
6
+ summarizer = pipeline("summarization")
7
+
8
+ def generate_summary(video_url):
9
+ # Get the video title and description from YouTube
10
+ yt = YouTube(video_url)
11
+ title = yt.title
12
+ description = yt.description
13
+
14
+ # Generate a summary of the video using the AI model
15
+ summary = summarizer(description, max_length=130, min_length=30, do_sample=False)
16
+
17
+ # Return the summary
18
+ return summary[0]["summary_text"]
19
+
20
+ # Create the Gradio interface
21
+ demo = gr.Interface(
22
+ generate_summary,
23
+ gr.Textbox(label="YouTube Video URL"),
24
+ gr.Textbox(label="Video Summary"),
25
+ title="AI Video Summarizer",
26
+ description="Enter a YouTube video URL to generate a summary of the video",
27
+ )
28
+
29
+ # Launch the Gradio application
30
+ if __name__ == "__main__":
31
+ demo.launch()