SuriRaja commited on
Commit
a03a679
·
verified ·
1 Parent(s): 9ae0b6c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
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()