Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -9,10 +9,12 @@ from config import openai_api_key
|
|
9 |
# Load the model
|
10 |
llm = load_model(openai_api_key)
|
11 |
|
|
|
12 |
def analyze_video(video_path, max_speakers, progress=gr.Progress()):
|
13 |
start_time = time.time()
|
14 |
if not video_path:
|
15 |
-
return [gr.Markdown("Please upload a video file.")] + [gr.update(visible=False)] *
|
|
|
16 |
|
17 |
progress(0, desc="Starting analysis...")
|
18 |
progress(0.2, desc="Starting transcription and diarization")
|
@@ -33,39 +35,40 @@ def analyze_video(video_path, max_speakers, progress=gr.Progress()):
|
|
33 |
|
34 |
output_components = []
|
35 |
|
36 |
-
# Add transcript
|
37 |
output_components.append(gr.Textbox(value=transcription, label="Transcript", lines=10, visible=True))
|
38 |
-
|
39 |
for speaker_id, speaker_charts in charts.items():
|
40 |
-
markdown_content = f"
|
|
|
|
|
|
|
41 |
speaker_explanations = explanations[speaker_id]
|
42 |
speaker_section = [
|
43 |
gr.Markdown(markdown_content, visible=True),
|
44 |
-
gr.
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
gr.
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
gr.Plot(value=speaker_charts.get("personality", None), visible=True),
|
55 |
-
gr.Textbox(value=speaker_explanations.get("personality", ""), label="Personality Disorders Explanation", visible=True),
|
56 |
-
])
|
57 |
]
|
58 |
output_components.extend(speaker_section)
|
59 |
|
60 |
-
|
61 |
-
|
62 |
|
63 |
-
#
|
64 |
-
|
65 |
-
|
66 |
|
67 |
return output_components
|
68 |
|
|
|
69 |
with gr.Blocks() as iface:
|
70 |
gr.Markdown("# AI Personality Detection")
|
71 |
gr.Markdown("Upload a video")
|
@@ -75,24 +78,27 @@ with gr.Blocks() as iface:
|
|
75 |
analyze_button = gr.Button("Analyze")
|
76 |
|
77 |
# Create output components
|
78 |
-
output_components = [
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
|
|
96 |
|
97 |
analyze_button.click(
|
98 |
fn=analyze_video,
|
|
|
9 |
# Load the model
|
10 |
llm = load_model(openai_api_key)
|
11 |
|
12 |
+
|
13 |
def analyze_video(video_path, max_speakers, progress=gr.Progress()):
|
14 |
start_time = time.time()
|
15 |
if not video_path:
|
16 |
+
return [gr.Markdown("Please upload a video file.")] + [gr.update(visible=False)] * 49 + [
|
17 |
+
"Analysis not started."]
|
18 |
|
19 |
progress(0, desc="Starting analysis...")
|
20 |
progress(0.2, desc="Starting transcription and diarization")
|
|
|
35 |
|
36 |
output_components = []
|
37 |
|
38 |
+
# Add transcript near the beginning
|
39 |
output_components.append(gr.Textbox(value=transcription, label="Transcript", lines=10, visible=True))
|
40 |
+
|
41 |
for speaker_id, speaker_charts in charts.items():
|
42 |
+
markdown_content = f"""
|
43 |
+
| {speaker_id} |
|
44 |
+
|-----------|
|
45 |
+
"""
|
46 |
speaker_explanations = explanations[speaker_id]
|
47 |
speaker_section = [
|
48 |
gr.Markdown(markdown_content, visible=True),
|
49 |
+
gr.Plot(value=speaker_charts.get("attachment", None), visible=True),
|
50 |
+
gr.Textbox(value=speaker_explanations.get("attachment", ""), label="Attachment Styles Explanation",
|
51 |
+
visible=True),
|
52 |
+
gr.Plot(value=speaker_charts.get("dimensions", None), visible=True),
|
53 |
+
gr.Plot(value=speaker_charts.get("bigfive", None), visible=True),
|
54 |
+
gr.Textbox(value=speaker_explanations.get("bigfive", ""), label="Big Five Traits Explanation",
|
55 |
+
visible=True),
|
56 |
+
gr.Plot(value=speaker_charts.get("personality", None), visible=True),
|
57 |
+
gr.Textbox(value=speaker_explanations.get("personality", ""), label="Personality Disorders Explanation",
|
58 |
+
visible=True),
|
|
|
|
|
|
|
59 |
]
|
60 |
output_components.extend(speaker_section)
|
61 |
|
62 |
+
while len(output_components) < 49:
|
63 |
+
output_components.extend([gr.update(visible=False)] * 8)
|
64 |
|
65 |
+
# Add execution info
|
66 |
+
output_components.append(
|
67 |
+
gr.Textbox(value=f"Completed in {int(execution_time)} seconds.", label="Execution Information", visible=True))
|
68 |
|
69 |
return output_components
|
70 |
|
71 |
+
|
72 |
with gr.Blocks() as iface:
|
73 |
gr.Markdown("# AI Personality Detection")
|
74 |
gr.Markdown("Upload a video")
|
|
|
78 |
analyze_button = gr.Button("Analyze")
|
79 |
|
80 |
# Create output components
|
81 |
+
output_components = []
|
82 |
+
|
83 |
+
# Add transcript output near the top
|
84 |
+
execution_info_box = gr.Textbox(label="Execution Information", value="N/A", lines=1)
|
85 |
+
output_components.append(execution_info_box)
|
86 |
+
|
87 |
+
for _ in range(3): # Assuming maximum of 3 speakers
|
88 |
+
output_components.extend([
|
89 |
+
gr.Markdown(visible=False),
|
90 |
+
gr.Plot(visible=False),
|
91 |
+
gr.Textbox(label="Attachment Styles Explanation", visible=False),
|
92 |
+
gr.Plot(visible=False),
|
93 |
+
gr.Plot(visible=False),
|
94 |
+
gr.Textbox(label="Big Five Traits Explanation", visible=False),
|
95 |
+
gr.Plot(visible=False),
|
96 |
+
gr.Textbox(label="Personality Disorders Explanation", visible=False),
|
97 |
+
])
|
98 |
+
|
99 |
+
# Add execution info component
|
100 |
+
transcript_output = gr.Textbox(label="Transcript", lines=10, visible=False)
|
101 |
+
output_components.append(transcript_output)
|
102 |
|
103 |
analyze_button.click(
|
104 |
fn=analyze_video,
|