Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Initialize the translation pipeline
|
5 |
+
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-mul-en")
|
6 |
+
|
7 |
+
# Function to perform translation
|
8 |
+
def translate(text):
|
9 |
+
result = translator(text)
|
10 |
+
return result[0]['translation_text']
|
11 |
+
|
12 |
+
# Create Gradio interface
|
13 |
+
iface = gr.Interface(fn=translate,
|
14 |
+
inputs="text",
|
15 |
+
outputs="text",
|
16 |
+
title="Language Translator",
|
17 |
+
description="Translate any language to English")
|
18 |
+
|
19 |
+
if __name__ == "__main__":
|
20 |
+
iface.launch()
|