Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -72,42 +72,47 @@ with gr.Blocks() as iface:
|
|
72 |
results = analyze_video(video_path, max_speakers)
|
73 |
|
74 |
if "error" in results:
|
75 |
-
return
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
return
|
106 |
-
|
|
|
107 |
analyze_button.click(
|
108 |
fn=run_analysis,
|
109 |
inputs=[video_input, max_speakers],
|
110 |
-
outputs=[
|
|
|
|
|
|
|
|
|
111 |
show_progress=True
|
112 |
)
|
113 |
|
|
|
72 |
results = analyze_video(video_path, max_speakers)
|
73 |
|
74 |
if "error" in results:
|
75 |
+
return [
|
76 |
+
"", # transcript
|
77 |
+
gr.Tabs(), # tabs
|
78 |
+
results["error"], # execution_info
|
79 |
+
] + [gr.update(visible=False)] * 24 # 8 components per tab * 3 tabs
|
80 |
+
|
81 |
+
transcript = results["transcript"]
|
82 |
+
execution_info = f"Completed in {results['execution_time']} seconds."
|
83 |
+
|
84 |
+
tab_updates = []
|
85 |
+
for i in range(3): # For each potential speaker
|
86 |
+
if i < len(results["charts"]):
|
87 |
+
speaker_id = list(results["charts"].keys())[i]
|
88 |
+
speaker_charts = results["charts"][speaker_id]
|
89 |
+
speaker_explanations = results["explanations"][speaker_id]
|
90 |
+
|
91 |
+
tab_updates.extend([
|
92 |
+
gr.update(visible=True, label=speaker_id), # Tab visibility and label
|
93 |
+
gr.update(value=f"## {speaker_id}", visible=True), # Markdown
|
94 |
+
gr.update(value=speaker_charts.get("attachment", None), visible=True), # Attachment plot
|
95 |
+
gr.update(value=speaker_explanations.get("attachment", ""), visible=True), # Attachment explanation
|
96 |
+
gr.update(value=speaker_charts.get("dimensions", None), visible=True), # Dimensions plot
|
97 |
+
gr.update(value=speaker_charts.get("bigfive", None), visible=True), # Big Five plot
|
98 |
+
gr.update(value=speaker_explanations.get("bigfive", ""), visible=True), # Big Five explanation
|
99 |
+
gr.update(value=speaker_charts.get("personality", None), visible=True), # Personality plot
|
100 |
+
gr.update(value=speaker_explanations.get("personality", ""), visible=True), # Personality explanation
|
101 |
+
])
|
102 |
+
else:
|
103 |
+
tab_updates.extend([gr.update(visible=False)] * 9) # Hide unused tab and its components
|
104 |
+
|
105 |
+
return [transcript, gr.Tabs.update(selected=0), execution_info] + tab_updates
|
106 |
+
|
107 |
+
# Modify the analyze_button.click setup
|
108 |
analyze_button.click(
|
109 |
fn=run_analysis,
|
110 |
inputs=[video_input, max_speakers],
|
111 |
+
outputs=[
|
112 |
+
transcript_output,
|
113 |
+
tabs_output,
|
114 |
+
execution_info_output
|
115 |
+
] + [component for tab in tabs_output.children for component in tab.children],
|
116 |
show_progress=True
|
117 |
)
|
118 |
|