File size: 904 Bytes
272f692
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from youtube_transcript_api import YouTubeTranscriptApi as yta
import gradio as gr

def transcript_generator(link):

  yt_link = str(link)
  yt_id = yt_link.partition("=")[2]

  data = yta.get_transcript(yt_id)

  transcript = ''
  for value in data:
    for key,val in value.items():
      if key == 'text':
        transcript += val

  return transcript


with gr.Blocks() as demo:


    input = gr.Textbox(label="Enter YouTube Link",value='',lines=1)
    output = gr.Textbox(label="Transcript",lines=10)
    btn = gr.Button(value="Submit")
    btn.click(transcript_generator, inputs=[input], outputs=[output])

    gr.Examples(
        [["https://www.youtube.com/watch?v=47dtFZ8CFo8"], ["https://www.youtube.com/watch?v=hT_nvWreIhg"],['https://www.youtube.com/watch?v=JP0PNEA_-X0']],
        [input],
        transcript_generator,
        
    )

if __name__ == "__main__":
    demo.launch(share=True)