Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
translator = pipeline("translation_en_to_hi", model="Helsinki-NLP/opus-mt-en-hi")
|
5 |
+
|
6 |
+
def translate_text(text):
|
7 |
+
result = translator(text)[0]['translation_text']
|
8 |
+
return result
|
9 |
+
|
10 |
+
iface = gr.Interface(fn=translate_text, inputs="text", outputs="text")
|
11 |
+
|
12 |
+
# Enable API mode
|
13 |
+
iface.launch()
|