Spaces:
Runtime error
Runtime error
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) |