Update app.py
Browse files
app.py
CHANGED
@@ -344,21 +344,19 @@ def main():
|
|
344 |
progress_bar.progress(40)
|
345 |
st.subheader("Speech Trajectory Analysis")
|
346 |
|
347 |
-
#
|
348 |
segments = analyzer.split_text(text, max_length=512)
|
349 |
num_segments = len(segments)
|
350 |
segment_labels = [f"{i+1}" for i in range(num_segments)]
|
351 |
-
sentiment_scores, basic_emotions = analyzer.analyze_emotional_trajectory(text)
|
352 |
|
353 |
-
# Get
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
moral_trajectories[foundation].append(moral_scores[foundation])
|
362 |
|
363 |
# Create unified figure
|
364 |
unified_fig = go.Figure()
|
|
|
344 |
progress_bar.progress(40)
|
345 |
st.subheader("Speech Trajectory Analysis")
|
346 |
|
347 |
+
# Process ALL data upfront
|
348 |
segments = analyzer.split_text(text, max_length=512)
|
349 |
num_segments = len(segments)
|
350 |
segment_labels = [f"{i+1}" for i in range(num_segments)]
|
|
|
351 |
|
352 |
+
# Get all analysis data at once
|
353 |
+
with st.spinner('Processing all analyses...'):
|
354 |
+
sentiment_scores, basic_emotions = analyzer.analyze_emotional_trajectory(text)
|
355 |
+
moral_trajectories = {foundation: [] for foundation in ['care', 'fairness', 'loyalty', 'authority', 'sanctity']}
|
356 |
+
for segment in segments:
|
357 |
+
moral_scores = analyzer.analyze_moral_foundations(segment)
|
358 |
+
for foundation in moral_trajectories.keys():
|
359 |
+
moral_trajectories[foundation].append(moral_scores[foundation])
|
|
|
360 |
|
361 |
# Create unified figure
|
362 |
unified_fig = go.Figure()
|