Spaces:
Runtime error
Runtime error
Commit
·
272f692
1
Parent(s):
f348d8d
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from youtube_transcript_api import YouTubeTranscriptApi as yta
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
def transcript_generator(link):
|
5 |
+
|
6 |
+
yt_link = str(link)
|
7 |
+
yt_id = yt_link.partition("=")[2]
|
8 |
+
|
9 |
+
data = yta.get_transcript(yt_id)
|
10 |
+
|
11 |
+
transcript = ''
|
12 |
+
for value in data:
|
13 |
+
for key,val in value.items():
|
14 |
+
if key == 'text':
|
15 |
+
transcript += val
|
16 |
+
|
17 |
+
return transcript
|
18 |
+
|
19 |
+
|
20 |
+
with gr.Blocks() as demo:
|
21 |
+
|
22 |
+
|
23 |
+
input = gr.Textbox(label="Enter YouTube Link",value='',lines=1)
|
24 |
+
output = gr.Textbox(label="Transcript",lines=10)
|
25 |
+
btn = gr.Button(value="Submit")
|
26 |
+
btn.click(transcript_generator, inputs=[input], outputs=[output])
|
27 |
+
|
28 |
+
gr.Examples(
|
29 |
+
[["https://www.youtube.com/watch?v=47dtFZ8CFo8"], ["https://www.youtube.com/watch?v=hT_nvWreIhg"],['https://www.youtube.com/watch?v=JP0PNEA_-X0']],
|
30 |
+
[input],
|
31 |
+
transcript_generator,
|
32 |
+
|
33 |
+
)
|
34 |
+
|
35 |
+
if __name__ == "__main__":
|
36 |
+
demo.launch(share=True)
|