File size: 1,225 Bytes
56ac5db
 
583462f
56ac5db
b984651
583462f
b984651
 
56ac5db
 
 
 
 
 
 
 
 
 
 
b984651
 
 
 
56ac5db
 
 
 
 
 
b984651
56ac5db
 
 
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
import gradio as gr
from tool import YouTubeTranscriptExtractor, TranscriptSummarizer

youtube_tool = YouTubeTranscriptExtractor()
#summarizer_tool = TranscriptSummarizer()

def process_youtube_video(video_url, hf_api_key):
    summarizer_tool = TranscriptSummarizer(hf_api_key=hf_api_key)
    transcript = youtube_tool.forward(video_url=video_url)
    summary_and_blog = summarizer_tool.forward(transcript=transcript)
    try:
        summary, image_url = summary_and_blog.split("\n\nImage URL: ")
    except ValueError:
        summary = summary_and_blog
        image_url = None
    return transcript, summary, image_url

iface = gr.Interface(
    fn=process_youtube_video,
    inputs=[
        gr.Textbox(label="YouTube Video URL"),
        gr.Textbox(label="Hugging Face API Key", type="password")
    ],
    outputs=[
        gr.Textbox(label="Transcript"),
        gr.Textbox(label="Summary and Blog Content"),
        gr.Image(label="Generated Image", image_mode="RGBA")
    ],
    title="YouTube Transcript Summarizer and Blog Content Generator",
    description="Enter a YouTube video URL and Hugging Face API Key to extract the transcript, summarize it, and generate blog content with an image."
)

iface.launch()