sophicist commited on
Commit
5d3ead6
·
1 Parent(s): 2d553a1

added the various models

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -61,8 +61,9 @@ def load_model_and_tokenizer(language):
61
  def translate_text(text):
62
  # Detect the language
63
  detected_language = detect_language(text)
 
64
  if detected_language not in lang_to_model:
65
- return f"Language '{detected_language}' is not supported for translation."
66
 
67
  # Load the appropriate model and tokenizer
68
  tokenizer, model = load_model_and_tokenizer(detected_language)
@@ -77,7 +78,8 @@ def translate_text(text):
77
 
78
  # Decode output
79
  translation = tokenizer.decode(outputs[0], skip_special_tokens=True)
80
- return translation
 
81
 
82
  # Define Gradio interface
83
  iface = gr.Interface(
 
61
  def translate_text(text):
62
  # Detect the language
63
  detected_language = detect_language(text)
64
+ print(f"Detected Language: {detected_language}") # Print detected language for the app output
65
  if detected_language not in lang_to_model:
66
+ return f"Detected Language: {detected_language}. Language not supported for translation."
67
 
68
  # Load the appropriate model and tokenizer
69
  tokenizer, model = load_model_and_tokenizer(detected_language)
 
78
 
79
  # Decode output
80
  translation = tokenizer.decode(outputs[0], skip_special_tokens=True)
81
+ return f"Detected Language: {detected_language}\nTranslation: {translation}"
82
+
83
 
84
  # Define Gradio interface
85
  iface = gr.Interface(