AamerAkhter commited on
Commit
2887a75
Β·
verified Β·
1 Parent(s): ecd6f07

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from deep_translator import GoogleTranslator
3
+
4
+ # 🎩 The Feather-Light Magic Trick!
5
+ def magic_translator(text, direction):
6
+ if direction == "English to Urdu":
7
+ # 🦜 The magic parrot flies and translates to Urdu
8
+ translated = GoogleTranslator(source='en', target='ur').translate(text)
9
+ return translated
10
+ else:
11
+ # 🦜 The magic parrot flies and translates to English
12
+ translated = GoogleTranslator(source='ur', target='en').translate(text)
13
+ return translated
14
+
15
+ # 🎁 Building the shiny Toy Box!
16
+ toy_box = gr.Interface(
17
+ fn=magic_translator,
18
+ inputs=[
19
+ gr.Textbox(lines=3, placeholder="Type your words here... ✍️", label="Your Words"),
20
+ gr.Radio(["English to Urdu", "Urdu to English"], label="Which way?", value="English to Urdu")
21
+ ],
22
+ outputs=gr.Textbox(label="Magic Answer! ✨"),
23
+ title="🌟 The Magic Language Box 🌟",
24
+ description="Type words, pick a direction, and watch the magic parrot do the work!"
25
+ )
26
+
27
+ # πŸš€ Turn it on!
28
+ toy_box.launch()