Spaces:
Runtime error
Runtime error
Created app.py
Browse files
app.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from youtube_transcript_api import YouTubeTranscriptApi
|
3 |
+
|
4 |
+
def get_transcript(youtube_url):
|
5 |
+
try:
|
6 |
+
# Extract the video ID from the YouTube URL
|
7 |
+
video_id = youtube_url.split("?v=")[1]
|
8 |
+
|
9 |
+
# Get the transcript
|
10 |
+
transcript = YouTubeTranscriptApi.get_transcript(video_id)
|
11 |
+
transcript_text = " ".join([entry["text"] for entry in transcript])
|
12 |
+
|
13 |
+
return transcript_text
|
14 |
+
except Exception as e:
|
15 |
+
return f"Error: {str(e)}"
|
16 |
+
|
17 |
+
|
18 |
+
interface = gr.Interface(
|
19 |
+
fn=get_transcript,
|
20 |
+
inputs=gr.components.Textbox(label="Enter YouTube URL"),
|
21 |
+
outputs=gr.components.Textbox(label="Transcript"),
|
22 |
+
title="YouTube Transcript Extractor",
|
23 |
+
description="Enter a YouTube URL to extract the transcript of the video.",
|
24 |
+
)
|
25 |
+
|
26 |
+
if __name__ == "__main__":
|
27 |
+
interface.launch()
|
28 |
+
|