Jesus Carrasco commited on
Commit
af1aba9
·
1 Parent(s): 5be9305

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -1,7 +1,8 @@
1
  import gradio as gr
2
- from gradio.components import Input, Output
3
  from transformers import MarianMTModel, MarianTokenizer
4
 
 
5
  # Define the translator function
6
  def translate_text(text, target_language):
7
  model_name = {
@@ -25,16 +26,21 @@ def translate_text(text, target_language):
25
 
26
  return translated_text
27
 
 
 
 
 
28
  # Define the Gradio interface
29
  language_options = ["Spanish", "French", "Italian", "Ukrainian"]
30
  inputs = [
31
- Input.Textbox(lines=5, label="Enter text to translate:"),
32
- Input.Dropdown(choices=language_options, label="Select target language:"),
33
  ]
34
- outputs = Output.Textbox(label="Translated text:")
35
 
36
  iface = gr.Interface(fn=translate_text, inputs=inputs, outputs=outputs, title="Language Translator")
37
 
38
- # Launch the Hugging Face Spaces app with share=True
39
- iface.launch(share=True)
 
40
 
 
1
  import gradio as gr
2
+ from gradio import inputs, outputs
3
  from transformers import MarianMTModel, MarianTokenizer
4
 
5
+
6
  # Define the translator function
7
  def translate_text(text, target_language):
8
  model_name = {
 
26
 
27
  return translated_text
28
 
29
+ # Define the translator function
30
+ def translate_text(text, target_language):
31
+ # ... (the rest of the code)
32
+
33
  # Define the Gradio interface
34
  language_options = ["Spanish", "French", "Italian", "Ukrainian"]
35
  inputs = [
36
+ inputs.Textbox(lines=5, label="Enter text to translate:"),
37
+ inputs.Dropdown(choices=language_options, label="Select target language:"),
38
  ]
39
+ outputs = outputs.Textbox(label="Translated text:")
40
 
41
  iface = gr.Interface(fn=translate_text, inputs=inputs, outputs=outputs, title="Language Translator")
42
 
43
+ # Launch the Hugging Face Spaces app
44
+ iface.launch()
45
+
46