emirhanbilgic commited on
Commit
1558a57
·
verified ·
1 Parent(s): a4affcf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -108,22 +108,23 @@ with gr.Blocks() as demo:
108
  sentences = split_text_into_sentences(text)
109
  all_audio = []
110
  all_text = ""
111
-
112
  for sentence in sentences:
113
  print(f"Processing sentence: {sentence[:50]}...") # Display the first 50 characters for a quick preview
114
  sample_rate, audio_arr = generate_single_wav_from_text(sentence, description)
115
  all_audio.append((sample_rate, audio_arr))
116
  all_text += f"**Sentence**: {sentence}\n\n"
117
-
118
  # Yield the accumulated results
119
- yield all_audio, all_text
120
-
121
  print("Processing complete.")
122
 
123
  def run_pipeline(pdf_input, translate_checkbox, source_lang, target_lang, description):
124
  # Stream outputs to Gradio interface
125
  for audio_data, markdown_text in handle_process(pdf_input, translate_checkbox, source_lang, target_lang, description):
126
- yield audio_data[-1], markdown_text
 
127
 
128
  def handle_translation_toggle(translate_checkbox):
129
  if translate_checkbox:
 
108
  sentences = split_text_into_sentences(text)
109
  all_audio = []
110
  all_text = ""
111
+
112
  for sentence in sentences:
113
  print(f"Processing sentence: {sentence[:50]}...") # Display the first 50 characters for a quick preview
114
  sample_rate, audio_arr = generate_single_wav_from_text(sentence, description)
115
  all_audio.append((sample_rate, audio_arr))
116
  all_text += f"**Sentence**: {sentence}\n\n"
117
+
118
  # Yield the accumulated results
119
+ yield all_audio.copy(), all_text # Use .copy() to avoid mutation issues
120
+
121
  print("Processing complete.")
122
 
123
  def run_pipeline(pdf_input, translate_checkbox, source_lang, target_lang, description):
124
  # Stream outputs to Gradio interface
125
  for audio_data, markdown_text in handle_process(pdf_input, translate_checkbox, source_lang, target_lang, description):
126
+ # Display all accumulated audio files and markdown text
127
+ yield [gr.Audio.update(value=(sample_rate, audio_arr)) for sample_rate, audio_arr in audio_data], markdown_text
128
 
129
  def handle_translation_toggle(translate_checkbox):
130
  if translate_checkbox: