reab5555 commited on
Commit
aea77a0
·
verified ·
1 Parent(s): a08a46f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -24
app.py CHANGED
@@ -27,7 +27,7 @@ def analyze_video(video_path, language_display_name, max_speakers, progress=gr.P
27
  start_time = time.time()
28
 
29
  if not video_path:
30
- return [gr.Markdown("Please upload a video file.")], "Analysis not started."
31
 
32
  # Convert the display name to the language code
33
  language = LANGUAGE_MAP[language_display_name]
@@ -66,30 +66,28 @@ def analyze_video(video_path, language_display_name, max_speakers, progress=gr.P
66
  for speaker_id, speaker_charts in charts.items():
67
  speaker_explanations = explanations[speaker_id]
68
 
69
- output_components.append(gr.Markdown(f"### {speaker_id}"))
70
-
71
- if "attachment" in speaker_charts:
72
- output_components.append(gr.Plot(speaker_charts["attachment"]))
73
- output_components.append(gr.Textbox(value=speaker_explanations.get("attachment", ""),
74
- label=f"Attachment Styles Explanation - {speaker_id}", lines=2))
75
-
76
- if "dimensions" in speaker_charts:
77
- output_components.append(gr.Plot(speaker_charts["dimensions"]))
78
-
79
- if "bigfive" in speaker_charts:
80
- output_components.append(gr.Plot(speaker_charts["bigfive"]))
81
- output_components.append(gr.Textbox(value=speaker_explanations.get("bigfive", ""),
82
- label=f"Big Five Traits Explanation - {speaker_id}", lines=2))
83
-
84
- if "personality" in speaker_charts:
85
- output_components.append(gr.Plot(speaker_charts["personality"]))
86
- output_components.append(gr.Textbox(value=speaker_explanations.get("personality", ""),
87
- label=f"Personality Disorders Explanation - {speaker_id}", lines=2))
88
 
89
  # Add the transcript at the end
90
  output_components.append(gr.Textbox(value=transcription, label="Transcript", lines=10))
91
 
92
- return output_components, f"Completed in {int(execution_time)} seconds."
 
 
 
 
 
 
 
93
 
94
  # Define the Gradio interface
95
  with gr.Blocks() as iface:
@@ -103,9 +101,7 @@ with gr.Blocks() as iface:
103
  analyze_button = gr.Button("Analyze")
104
 
105
  # Create placeholders for output components
106
- output_components = [gr.Markdown(visible=False) for _ in range(50)] # Adjust the number based on your maximum possible outputs
107
-
108
- # Execution time box
109
  execution_info_box = gr.Textbox(label="Execution Information", value="Waiting for analysis...", lines=2)
110
 
111
  analyze_button.click(
 
27
  start_time = time.time()
28
 
29
  if not video_path:
30
+ return [gr.Markdown("Please upload a video file.")] + [gr.Markdown(visible=False) for _ in range(48)] + ["Analysis not started."]
31
 
32
  # Convert the display name to the language code
33
  language = LANGUAGE_MAP[language_display_name]
 
66
  for speaker_id, speaker_charts in charts.items():
67
  speaker_explanations = explanations[speaker_id]
68
 
69
+ output_components.extend([
70
+ gr.Markdown(f"### {speaker_id}"),
71
+ gr.Plot(speaker_charts.get("attachment", None)) if "attachment" in speaker_charts else gr.Markdown(visible=False),
72
+ gr.Textbox(value=speaker_explanations.get("attachment", ""), label=f"Attachment Styles Explanation - {speaker_id}", lines=2) if "attachment" in speaker_charts else gr.Markdown(visible=False),
73
+ gr.Plot(speaker_charts.get("dimensions", None)) if "dimensions" in speaker_charts else gr.Markdown(visible=False),
74
+ gr.Plot(speaker_charts.get("bigfive", None)) if "bigfive" in speaker_charts else gr.Markdown(visible=False),
75
+ gr.Textbox(value=speaker_explanations.get("bigfive", ""), label=f"Big Five Traits Explanation - {speaker_id}", lines=2) if "bigfive" in speaker_charts else gr.Markdown(visible=False),
76
+ gr.Plot(speaker_charts.get("personality", None)) if "personality" in speaker_charts else gr.Markdown(visible=False),
77
+ gr.Textbox(value=speaker_explanations.get("personality", ""), label=f"Personality Disorders Explanation - {speaker_id}", lines=2) if "personality" in speaker_charts else gr.Markdown(visible=False),
78
+ ])
 
 
 
 
 
 
 
 
 
79
 
80
  # Add the transcript at the end
81
  output_components.append(gr.Textbox(value=transcription, label="Transcript", lines=10))
82
 
83
+ # Pad the output with invisible components if necessary
84
+ while len(output_components) < 49:
85
+ output_components.append(gr.Markdown(visible=False))
86
+
87
+ # Add the execution time
88
+ output_components.append(f"Completed in {int(execution_time)} seconds.")
89
+
90
+ return output_components
91
 
92
  # Define the Gradio interface
93
  with gr.Blocks() as iface:
 
101
  analyze_button = gr.Button("Analyze")
102
 
103
  # Create placeholders for output components
104
+ output_components = [gr.Markdown(visible=False) for _ in range(49)]
 
 
105
  execution_info_box = gr.Textbox(label="Execution Information", value="Waiting for analysis...", lines=2)
106
 
107
  analyze_button.click(