Mds21 commited on
Commit
2f95d6b
1 Parent(s): 04be83b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -1,14 +1,19 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
- translation_pipeline = pipeline('translation_en_to_de')
 
4
  # results = translation_pipeline('I love ice cream')
5
  # results[0]['translation_text']
6
- def translate_transformers(English):
7
- results = translation_pipeline(English)
 
 
 
8
  return results[0]['translation_text']
9
 
10
  interface = gr.Interface(fn=translate_transformers,
11
  inputs=gr.inputs.Textbox(lines=2, placeholder='Text to translate'),
 
12
  outputs='text')
13
 
14
  interface.launch()
 
1
  import gradio as gr
2
  from transformers import pipeline
3
+ translation_pipeline_german = pipeline('translation_en_to_de')
4
+ translation_pipeline_hindi = pipeline('translation_en_to_de')
5
  # results = translation_pipeline('I love ice cream')
6
  # results[0]['translation_text']
7
+ def translate_transformers(English,Language_To_Translate):
8
+ if "German" in Language_To_Translate:
9
+ results = translation_pipeline_german(English)
10
+ elif "Hindi" in Language_To_Translate:
11
+ results = translation_pipeline_hindi(English)
12
  return results[0]['translation_text']
13
 
14
  interface = gr.Interface(fn=translate_transformers,
15
  inputs=gr.inputs.Textbox(lines=2, placeholder='Text to translate'),
16
+ gr.CheckboxGroup(["German", "Hindi"]),
17
  outputs='text')
18
 
19
  interface.launch()