reab5555 commited on
Commit
30efc24
·
verified ·
1 Parent(s): 0c982ed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -34
app.py CHANGED
@@ -16,50 +16,24 @@ def create_interface():
16
  execution_time = gr.Textbox(label="Execution Time", visible=False)
17
  detected_language = gr.Textbox(label="Detected Language", visible=False)
18
 
19
- # Container for dynamically created charts and explanations
20
- output_container = gr.Column()
 
 
 
 
21
 
22
  def process_and_update(input_file):
23
  # Process the input
24
  results = process_input(input_file, progress=gr.Progress())
25
 
26
  # Create and update charts and explanations
27
- outputs = update_visibility_and_charts(*results)
28
-
29
- print("Outputs from process_and_update:", outputs)
30
-
31
- # Extract the first three outputs for status, execution time, and language
32
- status, exec_time, lang = outputs[:3]
33
-
34
- # Combine all chart and explanation outputs into a list of components
35
- dynamic_outputs = outputs[3:]
36
-
37
- # Create a list of Gradio components for the dynamic outputs
38
- dynamic_components = []
39
- for output in dynamic_outputs:
40
- if isinstance(output, gr.components.Plot):
41
- dynamic_components.append(gr.Plot())
42
- elif isinstance(output, gr.components.Textbox):
43
- dynamic_components.append(gr.Textbox())
44
-
45
- # Return all outputs
46
- return [status, exec_time, lang] + dynamic_outputs
47
-
48
- # Define the outputs for the interface
49
- outputs = [
50
- status_text,
51
- execution_time,
52
- detected_language,
53
- ]
54
- # Add dynamic output components
55
- for _ in range(6): # Assuming maximum 2 speakers and 3 analysis types
56
- outputs.append(gr.Plot())
57
- outputs.append(gr.Textbox())
58
 
59
  input_file.upload(
60
  fn=process_and_update,
61
  inputs=[input_file],
62
- outputs=outputs
63
  )
64
 
65
  return iface
 
16
  execution_time = gr.Textbox(label="Execution Time", visible=False)
17
  detected_language = gr.Textbox(label="Detected Language", visible=False)
18
 
19
+ # Create placeholders for charts and explanations
20
+ charts_and_explanations = []
21
+ for _ in range(6): # 3 analysis types * 2 speakers
22
+ with gr.Row():
23
+ charts_and_explanations.append(gr.Plot(visible=False))
24
+ charts_and_explanations.append(gr.Textbox(visible=False))
25
 
26
  def process_and_update(input_file):
27
  # Process the input
28
  results = process_input(input_file, progress=gr.Progress())
29
 
30
  # Create and update charts and explanations
31
+ return update_visibility_and_charts(*results)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
  input_file.upload(
34
  fn=process_and_update,
35
  inputs=[input_file],
36
+ outputs=[status_text, execution_time, detected_language] + charts_and_explanations
37
  )
38
 
39
  return iface