typesdigital commited on
Commit
cf6bbf2
·
1 Parent(s): af0922d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -14
app.py CHANGED
@@ -1,19 +1,16 @@
 
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(
@@ -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()