Krishna086 commited on
Commit
a640cbd
·
verified ·
1 Parent(s): 8f879af

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -113,15 +113,14 @@ def trigger_translation(translation_module, language_detector, audio_processor_m
113
  try:
114
  translated_text = translation_module.translate(user_input_text, source_lang_code, target_lang_code)
115
  if time.time() - start_time > 20: # Timeout after 20 seconds
116
- st.warning("This translation is not possible at this moment. Please try another language.")
117
- st.session_state.translated_text = user_input_text
118
- elif translated_text and len(translated_text.split()) > 2:
119
  st.session_state.translated_text = translated_text
120
  else:
121
- st.warning("This translation is not possible at this moment. Please try another language.")
122
  st.session_state.translated_text = user_input_text
123
- except Exception:
124
- st.warning("This translation is not possible at this moment. Please try another language.")
125
  st.session_state.translated_text = user_input_text
126
 
127
  # Handle audio playback with error handling
 
113
  try:
114
  translated_text = translation_module.translate(user_input_text, source_lang_code, target_lang_code)
115
  if time.time() - start_time > 20: # Timeout after 20 seconds
116
+ st.error("Translation took too long, reverting to input.")
117
+ translated_text = user_input_text
118
+ if translated_text and len(translated_text.split()) > 2:
119
  st.session_state.translated_text = translated_text
120
  else:
 
121
  st.session_state.translated_text = user_input_text
122
+ except Exception as e:
123
+ st.error(f"Translation failed: {e}")
124
  st.session_state.translated_text = user_input_text
125
 
126
  # Handle audio playback with error handling