Spaces:
Running
Running
import gradio as gr | |
from youtube_transcript_api import YouTubeTranscriptApi | |
def fetch_transcript(video_id): | |
try: | |
transcript = YouTubeTranscriptApi.get_transcript(video_id) | |
return '\n'.join([f"{entry['text']}" for entry in transcript]) | |
except Exception as e: | |
return f"Error: {str(e)}" | |
iface = gr.Interface( | |
fn=fetch_transcript, | |
inputs=gr.Textbox(label="YouTube Video ID"), | |
outputs=gr.Textbox(label="Transcript"), | |
title="YouTube Transcript Fetcher", | |
description="Enter a YouTube video ID to fetch its transcript." | |
) | |
iface.launch() | |