pratikshahp commited on
Commit
556a464
·
verified ·
1 Parent(s): 91c238b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -5,10 +5,20 @@ from transformers import pipeline
5
  translator = pipeline("translation_en_to_hi", model="Helsinki-NLP/opus-mt-en-hi")
6
 
7
  # Define the translation function
 
 
 
 
 
 
8
  def translate_text(text):
9
  if not text:
10
  return "⚠️ Please provide some input text."
11
- result = translator(text)[0]["translation_text"]
 
 
 
 
12
  return result
13
 
14
  # Create the Gradio interface
 
5
  translator = pipeline("translation_en_to_hi", model="Helsinki-NLP/opus-mt-en-hi")
6
 
7
  # Define the translation function
8
+ #def translate_text(text):
9
+ #if not text:
10
+ #return "⚠️ Please provide some input text."
11
+ #result = translator(text)[0]["translation_text"]
12
+ #return result
13
+
14
  def translate_text(text):
15
  if not text:
16
  return "⚠️ Please provide some input text."
17
+ result = translator(
18
+ text,
19
+ max_length=100,
20
+ clean_up_tokenization_spaces=True
21
+ )[0]["translation_text"]
22
  return result
23
 
24
  # Create the Gradio interface