Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -24,7 +24,7 @@ def analyze_video(video_path, max_speakers, progress=gr.Progress()):
|
|
24 |
progress(0.7, desc="Transcription processing complete.")
|
25 |
|
26 |
progress(0.9, desc="Generating charts")
|
27 |
-
charts, explanations = create_charts(results)
|
28 |
progress(1.0, desc="Charts generation complete.")
|
29 |
|
30 |
end_time = time.time()
|
@@ -33,29 +33,47 @@ def analyze_video(video_path, max_speakers, progress=gr.Progress()):
|
|
33 |
output = {
|
34 |
"transcript": transcription,
|
35 |
"execution_info": f"Completed in {int(execution_time)} seconds.",
|
36 |
-
"speakers":
|
|
|
37 |
}
|
38 |
|
39 |
-
for speaker_id, speaker_charts in charts.items():
|
40 |
-
speaker_explanations = explanations[speaker_id]
|
41 |
-
output["speakers"][speaker_id] = {
|
42 |
-
"attachment": {
|
43 |
-
"chart": speaker_charts["attachment"],
|
44 |
-
"explanation": speaker_explanations["attachment"]
|
45 |
-
},
|
46 |
-
"dimensions": speaker_charts["dimensions"],
|
47 |
-
"bigfive": {
|
48 |
-
"chart": speaker_charts["bigfive"],
|
49 |
-
"explanation": speaker_explanations["bigfive"]
|
50 |
-
},
|
51 |
-
"personality": {
|
52 |
-
"chart": speaker_charts["personality"],
|
53 |
-
"explanation": speaker_explanations["personality"]
|
54 |
-
}
|
55 |
-
}
|
56 |
-
|
57 |
return output
|
58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
def update_interface(result, max_speakers):
|
60 |
if "error" in result:
|
61 |
return [result["error"], gr.update(visible=False)] + [gr.update(visible=False)] * 42
|
|
|
24 |
progress(0.7, desc="Transcription processing complete.")
|
25 |
|
26 |
progress(0.9, desc="Generating charts")
|
27 |
+
charts, explanations = create_charts(json.loads(results))
|
28 |
progress(1.0, desc="Charts generation complete.")
|
29 |
|
30 |
end_time = time.time()
|
|
|
33 |
output = {
|
34 |
"transcript": transcription,
|
35 |
"execution_info": f"Completed in {int(execution_time)} seconds.",
|
36 |
+
"speakers": charts,
|
37 |
+
"explanations": explanations
|
38 |
}
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
return output
|
41 |
|
42 |
+
def update_interface(result, max_speakers):
|
43 |
+
if "error" in result:
|
44 |
+
return [result["error"], gr.update(visible=False)] + [gr.update(visible=False)] * 42
|
45 |
+
|
46 |
+
outputs = [
|
47 |
+
result["transcript"], # Transcript
|
48 |
+
result["execution_info"] # Execution info
|
49 |
+
]
|
50 |
+
|
51 |
+
for i in range(3):
|
52 |
+
speaker_id = i
|
53 |
+
if i < max_speakers and speaker_id in result["speakers"]:
|
54 |
+
speaker_data = result["speakers"][speaker_id]
|
55 |
+
speaker_explanations = result["explanations"][speaker_id]
|
56 |
+
outputs.extend([
|
57 |
+
gr.update(value=speaker_data["attachment"], visible=True),
|
58 |
+
gr.update(visible=True), # Column visibility
|
59 |
+
gr.update(value=speaker_explanations["attachment"], visible=True),
|
60 |
+
gr.update(visible=True), # Column visibility
|
61 |
+
gr.update(value=speaker_data["dimensions"], visible=True),
|
62 |
+
gr.update(visible=True), # Column visibility
|
63 |
+
gr.update(value=speaker_data["bigfive"], visible=True),
|
64 |
+
gr.update(visible=True), # Column visibility
|
65 |
+
gr.update(value=speaker_explanations["bigfive"], visible=True),
|
66 |
+
gr.update(visible=True), # Column visibility
|
67 |
+
gr.update(value=speaker_data["personality"], visible=True),
|
68 |
+
gr.update(visible=True), # Column visibility
|
69 |
+
gr.update(value=speaker_explanations["personality"], visible=True),
|
70 |
+
gr.update(visible=True), # Column visibility
|
71 |
+
])
|
72 |
+
else:
|
73 |
+
outputs.extend([gr.update(visible=False)] * 14) # 7 components + 7 columns
|
74 |
+
|
75 |
+
return outputs
|
76 |
+
|
77 |
def update_interface(result, max_speakers):
|
78 |
if "error" in result:
|
79 |
return [result["error"], gr.update(visible=False)] + [gr.update(visible=False)] * 42
|