kambris commited on
Commit
0aac7b0
·
verified ·
1 Parent(s): 62470b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -11
app.py CHANGED
@@ -344,21 +344,19 @@ def main():
344
  progress_bar.progress(40)
345
  st.subheader("Speech Trajectory Analysis")
346
 
347
- # Create consistent segments and get 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
- sentiment_scores, basic_emotions = analyzer.analyze_emotional_trajectory(text)
352
 
353
- # Get moral foundations data
354
- moral_trajectories = {
355
- 'care': [], 'fairness': [], 'loyalty': [],
356
- 'authority': [], 'sanctity': []
357
- }
358
- for segment in segments:
359
- moral_scores = analyzer.analyze_moral_foundations(segment)
360
- for foundation in moral_trajectories.keys():
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()