Spaces:
Runtime error
Runtime error
File size: 826 Bytes
85fad53 |
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 |
import gradio as gr
from youtube_transcript_api import YouTubeTranscriptApi
def get_transcript(youtube_url):
try:
# Extract the video ID from the YouTube URL
video_id = youtube_url.split("?v=")[1]
# Get the transcript
transcript = YouTubeTranscriptApi.get_transcript(video_id)
transcript_text = " ".join([entry["text"] for entry in transcript])
return transcript_text
except Exception as e:
return f"Error: {str(e)}"
interface = gr.Interface(
fn=get_transcript,
inputs=gr.components.Textbox(label="Enter YouTube URL"),
outputs=gr.components.Textbox(label="Transcript"),
title="YouTube Transcript Extractor",
description="Enter a YouTube URL to extract the transcript of the video.",
)
if __name__ == "__main__":
interface.launch()
|