amarkc's picture
Update app.py
351ec52
raw
history blame
No virus
1.28 kB
from youtube_transcript_api import YouTubeTranscriptApi
import gradio as gr
from gradio.mix import Series
def generate_transcript(url):
id = url[url.index("=")+1:]
transcript = YouTubeTranscriptApi.get_transcript(id)
script = ""
for text in transcript:
t = text["text"]
if t != '[Music]':
script += t + " "
return script
transcriber = gr.Interface(generate_transcript, 'text', 'text')
summarizer = gr.Interface.load("huggingface/sshleifer/distilbart-cnn-12-6")
gradio_ui = Series(transcriber, summarizer,
inputs = gr.inputs.Textbox(label = "Enter the YouTube URL below:"),
outputs = gr.outputs.Textbox(label = "Transcript Summary"),
examples = ["https://www.youtube.com/watch?v=Cu3R5it4cQs&list", "https://www.youtube.com/watch?v=HB4I2CgkcCo"],
title = "YouTube Transcript Summarizer",
theme = "peach",
description = "This application uses the sshleifer/distilbart-cnn-12-6 model to summarize a short YouTube video that has English subtitles. For it to work, the input URL must follow the format similar to the given examples, specifically having the video's ID at the end.")
gradio_ui.launch()