Spaces:
Runtime error
Runtime error
Commit
·
4496fc2
1
Parent(s):
724ee60
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,9 @@
|
|
1 |
from youtube_transcript_api import YouTubeTranscriptApi as yta
|
2 |
import gradio as gr
|
|
|
3 |
|
4 |
-
|
|
|
5 |
|
6 |
yt_link = str(link)
|
7 |
yt_id = yt_link.partition("=")[2]
|
@@ -14,22 +16,27 @@ def transcript_generator(link):
|
|
14 |
if key == 'text':
|
15 |
transcript += val
|
16 |
|
17 |
-
|
|
|
18 |
|
|
|
19 |
|
20 |
with gr.Blocks() as demo:
|
21 |
|
22 |
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
25 |
btn = gr.Button(value="Submit")
|
26 |
-
btn.click(transcript_generator, inputs=[
|
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=
|
30 |
-
[
|
31 |
transcript_generator,
|
32 |
-
|
33 |
)
|
34 |
|
35 |
if __name__ == "__main__":
|
|
|
1 |
from youtube_transcript_api import YouTubeTranscriptApi as yta
|
2 |
import gradio as gr
|
3 |
+
from googletrans import Translator
|
4 |
|
5 |
+
opts = ['afrikaans', 'albanian', 'amharic', 'arabic', 'armenian', 'azerbaijani', 'basque', 'belarusian', 'bengali', 'bosnian', 'bulgarian', 'catalan', 'cebuano', 'chichewa', 'chinese (simplified)', 'chinese (traditional)', 'corsican', 'croatian', 'czech', 'danish', 'dutch', 'english', 'esperanto', 'estonian', 'filipino', 'finnish', 'french', 'frisian', 'galician', 'georgian', 'german', 'greek', 'gujarati', 'haitian creole', 'hausa', 'hawaiian', 'hebrew', 'hebrew', 'hindi', 'hmong', 'hungarian', 'icelandic', 'igbo', 'indonesian', 'irish', 'italian', 'japanese', 'javanese', 'kannada', 'kazakh', 'khmer', 'korean', 'kurdish (kurmanji)', 'kyrgyz', 'lao', 'latin', 'latvian', 'lithuanian', 'luxembourgish', 'macedonian', 'malagasy', 'malay', 'malayalam', 'maltese', 'maori', 'marathi', 'mongolian', 'myanmar (burmese)', 'nepali', 'norwegian', 'odia', 'pashto', 'persian', 'polish', 'portuguese', 'punjabi', 'romanian', 'russian', 'samoan', 'scots gaelic', 'serbian', 'sesotho', 'shona', 'sindhi', 'sinhala', 'slovak', 'slovenian', 'somali', 'spanish', 'sundanese', 'swahili', 'swedish', 'tajik', 'tamil', 'telugu', 'thai', 'turkish', 'ukrainian', 'urdu', 'uyghur', 'uzbek', 'vietnamese', 'welsh', 'xhosa', 'yiddish', 'yoruba', 'zulu']
|
6 |
+
def transcript_generator(link,option):
|
7 |
|
8 |
yt_link = str(link)
|
9 |
yt_id = yt_link.partition("=")[2]
|
|
|
16 |
if key == 'text':
|
17 |
transcript += val
|
18 |
|
19 |
+
translator = Translator()
|
20 |
+
translation = translator.translate(transcript, dest = option).text
|
21 |
|
22 |
+
return transcript,translation
|
23 |
|
24 |
with gr.Blocks() as demo:
|
25 |
|
26 |
|
27 |
+
input1 = gr.Textbox(label="Enter YouTube Link",value='',lines=1)
|
28 |
+
input2 = gr.Dropdown(opts)
|
29 |
+
with gr.Tab("Transcript"):
|
30 |
+
output1 = gr.Textbox(label="Transcript",lines=10)
|
31 |
+
with gr.Tab("Translated Transcript"):
|
32 |
+
output2 = gr.Textbox(label="Translation",lines=10)
|
33 |
btn = gr.Button(value="Submit")
|
34 |
+
btn.click(transcript_generator, inputs=[input1,input2], outputs=[output1,output2])
|
35 |
|
36 |
gr.Examples(
|
37 |
+
[["https://www.youtube.com/watch?v=47dtFZ8CFo8",'chinese (simplified)'], ["https://www.youtube.com/watch?v=hT_nvWreIhg",'french'],['https://www.youtube.com/watch?v=PMs76lrqiA4','urdu']],
|
38 |
+
[input1,input2],
|
39 |
transcript_generator,
|
|
|
40 |
)
|
41 |
|
42 |
if __name__ == "__main__":
|