sohailq commited on
Commit
63267a9
1 Parent(s): 1d64def

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -1,15 +1,14 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
- from space import Space
4
 
5
- # Load the Space model for English to Urdu translation
6
- space = Space("Helsinki-NLP/opus-mt-en-ur")
7
 
8
  # Create a Gradio interface for the translation app
9
  def translate(text):
10
- # Use the Space model to translate the input text
11
- result = space.translate(text)
12
- return result
13
 
14
  input_text = gr.inputs.Textbox(label="Input English Text")
15
  output_text = gr.outputs.Textbox(label="Output Urdu Text")
 
1
  import gradio as gr
2
  from transformers import pipeline
 
3
 
4
+ # Load the English to Urdu translation model from the transformers library
5
+ translator = pipeline("translation_en_to_ur")
6
 
7
  # Create a Gradio interface for the translation app
8
  def translate(text):
9
+ # Use the translator pipeline to translate the input text
10
+ result = translator(text, max_length=500)
11
+ return result[0]['translation_text']
12
 
13
  input_text = gr.inputs.Textbox(label="Input English Text")
14
  output_text = gr.outputs.Textbox(label="Output Urdu Text")