Krishna086 commited on
Commit
884dae5
·
verified ·
1 Parent(s): 89fcb89

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -7
app.py CHANGED
@@ -113,15 +113,13 @@ 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.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
127
  def play_audio(audio_processor_module):
 
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.session_state.translated_text = user_input_text # Revert silently
117
+ elif translated_text and len(translated_text.split()) > 2:
 
118
  st.session_state.translated_text = translated_text
119
  else:
120
+ st.session_state.translated_text = user_input_text # Revert silently for other failures
121
+ except Exception:
122
+ st.session_state.translated_text = user_input_text # Revert silently on exception
 
123
 
124
  # Handle audio playback with error handling
125
  def play_audio(audio_processor_module):