dschandra commited on
Commit
61693da
·
verified ·
1 Parent(s): 3c48c73

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+ import gradio as gr
3
+ from transformers import pipeline
4
+
5
+ # Load the translation pipeline from Hugging Face
6
+ translator = pipeline("translation", model="Helsinki-NLP/opus-mt-mul-en")
7
+
8
+ def translate_to_english(text):
9
+ # Translate the input text to English
10
+ translation = translator(text)[0]['translation_text']
11
+ return translation
12
+
13
+ # Define the Gradio interface
14
+ iface = gr.Interface(
15
+ fn=translate_to_english,
16
+ inputs="text",
17
+ outputs="text",
18
+ title="Language to English Translator",
19
+ description="Type any text in any language, and this app will translate it to English."
20
+ )
21
+
22
+ # Launch the Gradio app
23
+ if __name__ == "__main__":
24
+ iface.launch()