srinikesh1432 commited on
Commit
c48dd86
·
verified ·
1 Parent(s): e85d07d

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +28 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load translation pipeline (English to French by default)
5
+ translator = pipeline("translation_en_to_fr", model="Helsinki-NLP/opus-mt-en-fr")
6
+
7
+ def translate_text(text):
8
+ result = translator(text, max_length=100)
9
+ return result[0]['translation_text']
10
+
11
+ with gr.Blocks() as demo:
12
+ gr.Markdown("## 🌍 Language Translation App (English → French)")
13
+
14
+ with gr.Row():
15
+ input_text = gr.Textbox(
16
+ lines=5,
17
+ placeholder="Enter English text here...",
18
+ label="English Text"
19
+ )
20
+ output_text = gr.Textbox(
21
+ lines=5,
22
+ label="French Translation"
23
+ )
24
+
25
+ translate_btn = gr.Button("Translate")
26
+ translate_btn.click(fn=translate_text, inputs=input_text, outputs=output_text)
27
+
28
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio>=3.30
2
+ transformers>=4.40
3
+ torch>=1.13