Spaces:
Runtime error
Runtime error
Commit
·
cf6bbf2
1
Parent(s):
af0922d
Update app.py
Browse files
app.py
CHANGED
@@ -1,19 +1,16 @@
|
|
|
|
1 |
from youtube_transcript_api import YouTubeTranscriptApi
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
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(
|
@@ -27,4 +24,4 @@ iface = gr.Interface(
|
|
27 |
)
|
28 |
|
29 |
# Launch the Gradio interface
|
30 |
-
iface.launch()
|
|
|
1 |
+
import gradio as gr
|
2 |
from youtube_transcript_api import YouTubeTranscriptApi
|
3 |
|
4 |
+
def get_transcript(video_id):
|
5 |
+
try:
|
6 |
+
# Retrieve the transcript
|
7 |
+
transcript = YouTubeTranscriptApi.get_transcript(video_id)
|
8 |
|
9 |
+
# Extract and return the text
|
10 |
+
text = '\n'.join([entry['text'] for entry in transcript])
|
11 |
+
return text
|
12 |
+
except Exception as e:
|
13 |
+
return f"Error: {e}"
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
# Create a Gradio interface
|
16 |
iface = gr.Interface(
|
|
|
24 |
)
|
25 |
|
26 |
# Launch the Gradio interface
|
27 |
+
iface.launch()
|