Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
from backend.text_to_tgt import src_txt_to_eng_translator
|
| 4 |
+
from backend.audio_to_tgt import src_audio_to_eng_translator
|
| 5 |
+
from backend.image_to_tgt import src_image_to_eng_translator
|
| 6 |
+
from backend.video_to_tgt import src_video_to_eng_translator
|
| 7 |
+
|
| 8 |
+
heading_txt = "Text-to-English"
|
| 9 |
+
description_txt = '''Enter text in any language, and get the translation in English.'''
|
| 10 |
+
|
| 11 |
+
txt_interface = gr.Interface(
|
| 12 |
+
fn=src_txt_to_eng_translator,
|
| 13 |
+
inputs=[
|
| 14 |
+
gr.Textbox(label="Playlist Link"),
|
| 15 |
+
],
|
| 16 |
+
outputs=gr.Textbox(label="Translation"),
|
| 17 |
+
title=heading_txt,
|
| 18 |
+
description=description_txt
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
heading_image = "Image-to-English"
|
| 22 |
+
description_image = "Upload an image to extract text and translate it to English."
|
| 23 |
+
|
| 24 |
+
image_interface = gr.Interface(
|
| 25 |
+
fn=src_image_to_eng_translator,
|
| 26 |
+
inputs=gr.Image(label="Upload an Image", type="file"),
|
| 27 |
+
outputs=gr.Textbox(label="Translated Text in English"),
|
| 28 |
+
title="Image Text Extractor and Translator",
|
| 29 |
+
description=description_image,
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
heading_audio = "Audio-to-English"
|
| 33 |
+
description_audio = "Upload an audio file to extract text and translate it to English."
|
| 34 |
+
|
| 35 |
+
audio_interface = gr.Interface(
|
| 36 |
+
fn=src_audio_to_eng_translator,
|
| 37 |
+
inputs=gr.Audio(label="Upload an Audio file", type="file"),
|
| 38 |
+
outputs=gr.Textbox(label="Translated Text in English"),
|
| 39 |
+
title=heading_audio,
|
| 40 |
+
description=description_audio
|
| 41 |
+
)
|
| 42 |
+
combined_interface = gr.TabbedInterface(
|
| 43 |
+
[txt_interface, image_interface, audio_interface],
|
| 44 |
+
['Text-to-English', 'Image-to-English', 'Audio-to-English']
|
| 45 |
+
)
|
| 46 |
+
|
| 47 |
+
combined_interface.launch()
|