|
import gradio as gr |
|
from tool import YouTubeTranscriptExtractor, TranscriptSummarizer |
|
|
|
youtube_tool = YouTubeTranscriptExtractor() |
|
|
|
|
|
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() |
|
|