Spaces:
Sleeping
Sleeping
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,25 +0,0 @@
|
|
| 1 |
-
!pip install transformers gradio
|
| 2 |
-
|
| 3 |
-
from transformers import pipeline
|
| 4 |
-
import gradio as gr
|
| 5 |
-
|
| 6 |
-
en_to_ur = pipeline("translation", model="Helsinki-NLP/opus-mt-en-ur")
|
| 7 |
-
ur_to_en = pipeline("translation", model="Helsinki-NLP/opus-mt-ur-en")
|
| 8 |
-
|
| 9 |
-
def translate(text, direction):
|
| 10 |
-
if direction == "English to Urdu":
|
| 11 |
-
return en_to_ur(text)[0]['translation_text']
|
| 12 |
-
else:
|
| 13 |
-
return ur_to_en(text)[0]['translation_text']
|
| 14 |
-
|
| 15 |
-
iface = gr.Interface(
|
| 16 |
-
fn=translate,
|
| 17 |
-
inputs=[
|
| 18 |
-
gr.Textbox(lines=5, label="Enter text"),
|
| 19 |
-
gr.Dropdown(["English to Urdu", "Urdu to English"], label="Direction")
|
| 20 |
-
],
|
| 21 |
-
outputs=gr.Textbox(label="Translation"),
|
| 22 |
-
title="English ↔ Urdu Translator"
|
| 23 |
-
)
|
| 24 |
-
|
| 25 |
-
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|