reab5555 commited on
Commit
edd1c74
·
verified ·
1 Parent(s): 897d8ef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -31
app.py CHANGED
@@ -33,49 +33,54 @@ def analyze_video(video_path, progress=gr.Progress()):
33
 
34
  output_components = [transcription] # transcript
35
 
36
- for i in range(3):
37
- speaker_id = f"Speaker {i+1}" if i < len(charts) else f"Speaker {i+1} (Not Present)"
38
- speaker_charts = charts.get(speaker_id, {})
39
- speaker_explanations = explanations.get(speaker_id, {})
40
- speaker_general_impression = general_impressions.get(speaker_id, "No data for this speaker")
41
-
42
- speaker_section1 = [
43
- gr.Markdown(f"# {speaker_id}", visible=True),
44
- gr.Textbox(value=speaker_general_impression, label="General Impression", visible=True)
45
- ]
46
-
47
- speaker_section2 = [
48
- gr.Plot(value=speaker_charts.get("attachment", None), visible=True),
49
- gr.Plot(value=speaker_charts.get("dimensions", None), visible=True),
50
- gr.Textbox(value=speaker_explanations.get("attachment", ""), label="Attachment Styles Explanation", visible=True)
51
- ]
52
-
53
- speaker_section3 = [
54
- gr.Plot(value=speaker_charts.get("bigfive", None), visible=True),
55
- gr.Textbox(value=speaker_explanations.get("bigfive", ""), label="Big Five Traits Explanation", visible=True)
56
- ]
57
-
58
- speaker_section4 = [
59
- gr.Plot(value=speaker_charts.get("personality", None), visible=True),
60
- gr.Textbox(value=speaker_explanations.get("personality", ""), label="Personality Disorders Explanation", visible=True)
61
- ]
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  output_components.extend(speaker_section1)
64
  output_components.extend(speaker_section2)
65
  output_components.extend(speaker_section3)
66
  output_components.extend(speaker_section4)
67
-
68
- output_components.append(f"Completed in {int(execution_time)} seconds.") # execution info
69
 
70
- # Pad with None for any missing speakers
71
- while len(output_components) < 28:
72
  output_components.extend([gr.update(visible=False)] * 9)
73
 
 
 
74
  return output_components
75
 
76
  def update_output(*args):
77
  return [gr.update(value=arg, visible=arg is not None) for arg in args]
78
-
79
  def use_example():
80
  return "examples/Scenes.From.A.Marriage.US.mp4"
81
 
 
33
 
34
  output_components = [transcription] # transcript
35
 
36
+ for i, (speaker_id, speaker_charts) in enumerate(charts.items(), start=1):
37
+ print(speaker_id)
38
+ speaker_explanations = explanations[speaker_id]
39
+ speaker_general_impression = general_impressions[speaker_id]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
+ with gr.Tab(visible=True):
42
+ with gr.TabItem(label=f'General Impression'):
43
+ speaker_section1 = [
44
+ gr.Markdown(f"# {speaker_id}", visible=True),
45
+ gr.Textbox(value=speaker_general_impression, label="General Impression", visible=True)
46
+ ]
47
+
48
+ with gr.TabItem(label=f'Attachment Styles'):
49
+ with gr.Row():
50
+ speaker_section2 = [
51
+ gr.Plot(value=speaker_charts.get("attachment", None), visible=True),
52
+ gr.Plot(value=speaker_charts.get("dimensions", None), visible=True),
53
+ gr.Textbox(value=speaker_explanations.get("attachment", ""), label="Attachment Styles Explanation", visible=True)
54
+ ]
55
+
56
+ with gr.TabItem(label=f'Big Five Traits'):
57
+ speaker_section3 = [
58
+ gr.Plot(value=speaker_charts.get("bigfive", None), visible=True),
59
+ gr.Textbox(value=speaker_explanations.get("bigfive", ""), label="Big Five Traits Explanation", visible=True)
60
+ ]
61
+
62
+ with gr.TabItem(label=f'Personalities'):
63
+ speaker_section4 = [
64
+ gr.Plot(value=speaker_charts.get("personality", None), visible=True),
65
+ gr.Textbox(value=speaker_explanations.get("personality", ""), label="Personality Disorders Explanation", visible=True)
66
+ ]
67
+
68
  output_components.extend(speaker_section1)
69
  output_components.extend(speaker_section2)
70
  output_components.extend(speaker_section3)
71
  output_components.extend(speaker_section4)
 
 
72
 
73
+ # Pad with None for any missing speakers
74
+ while len(output_components) < 28:
75
  output_components.extend([gr.update(visible=False)] * 9)
76
 
77
+ output_components.append(f"Completed in {int(execution_time)} seconds.") # execution info
78
+
79
  return output_components
80
 
81
  def update_output(*args):
82
  return [gr.update(value=arg, visible=arg is not None) for arg in args]
83
+
84
  def use_example():
85
  return "examples/Scenes.From.A.Marriage.US.mp4"
86