Spaces:
Runtime error
Runtime error
Commit
·
af0922d
1
Parent(s):
f3dcf48
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from youtube_transcript_api import YouTubeTranscriptApi
|
2 |
+
|
3 |
+
# Define the video ID (you can get this from the YouTube video URL)
|
4 |
+
video_id = 'Fnt6P7Rnho8'
|
5 |
+
|
6 |
+
try:
|
7 |
+
# Retrieve the transcript
|
8 |
+
transcript = YouTubeTranscriptApi.get_transcript(video_id)
|
9 |
+
|
10 |
+
# Extract and print the text
|
11 |
+
text = '\n'.join([entry['text'] for entry in transcript])
|
12 |
+
|
13 |
+
print("Transcript:")
|
14 |
+
print(text)
|
15 |
+
except Exception as e:
|
16 |
+
print(f"Error: {e}")
|
17 |
+
|
18 |
+
# Create a Gradio interface
|
19 |
+
iface = gr.Interface(
|
20 |
+
fn=get_transcript,
|
21 |
+
inputs="text",
|
22 |
+
outputs="text",
|
23 |
+
layout="vertical",
|
24 |
+
title="YouTube Video Transcript",
|
25 |
+
description="Enter a YouTube video ID to get its transcript.",
|
26 |
+
theme="default",
|
27 |
+
)
|
28 |
+
|
29 |
+
# Launch the Gradio interface
|
30 |
+
iface.launch()
|