norhan12 commited on
Commit
482bddd
·
verified ·
1 Parent(s): f8d3eaf

Update process_interview.py

Browse files
Files changed (1) hide show
  1. process_interview.py +13 -16
process_interview.py CHANGED
@@ -491,29 +491,26 @@ def generate_voice_interpretation(analysis: Dict) -> str:
491
  return "\n".join(interpretation_lines)
492
 
493
 
494
- # --- Chart Generation Function ---
495
- def generate_anxiety_confidence_chart(composite_scores: Dict, chart_path: str):
496
  try:
497
  labels = ['Anxiety', 'Confidence']
498
  scores = [composite_scores.get('anxiety', 0), composite_scores.get('confidence', 0)]
499
-
500
- fig, ax = plt.subplots(figsize=(4, 2.5)) # Smaller size for embedding in PDF
501
- ax.bar(labels, scores, color=['lightcoral', 'lightskyblue'])
502
- ax.set_ylabel('Score')
503
- ax.set_title('Anxiety vs. Confidence Scores')
504
- ax.set_ylim(0, 1.0) # Assuming scores are normalized 0-1
505
-
506
- for i, v in enumerate(scores):
507
- ax.text(i, v + 0.05, f"{v:.2f}", color='black', ha='center', fontweight='bold')
508
-
509
- # هذه الأوامر يجب أن تكون خارج الـ loop عشان يتم تنفيذها مرة واحدة بعد رسم كل العناصر
510
  plt.tight_layout()
511
- plt.savefig(chart_path)
512
- plt.close(fig) # Close the figure to free up memory
513
  except Exception as e:
514
  logger.error(f"Error generating chart: {str(e)}")
515
 
516
-
517
  # --- Acceptance Probability Calculation ---
518
  def calculate_acceptance_probability(analysis_data: Dict) -> float:
519
  """
 
491
  return "\n".join(interpretation_lines)
492
 
493
 
494
+ def generate_anxiety_confidence_chart(composite_scores: Dict, chart_path_or_buffer):
 
495
  try:
496
  labels = ['Anxiety', 'Confidence']
497
  scores = [composite_scores.get('anxiety', 0), composite_scores.get('confidence', 0)]
498
+ fig, ax = plt.subplots(figsize=(5, 3))
499
+ bars = ax.bar(labels, scores, color=['#FF6B6B', '#4ECDC4'], edgecolor='black', width=0.6)
500
+ ax.set_ylabel('Score (Normalized)', fontsize=12)
501
+ ax.set_title('Vocal Dynamics: Anxiety vs. Confidence', fontsize=14, pad=15)
502
+ ax.set_ylim(0, 1.2)
503
+ for bar in bars:
504
+ height = bar.get_height()
505
+ ax.text(bar.get_x() + bar.get_width()/2, height + 0.05, f"{height:.2f}",
506
+ ha='center', color='black', fontweight='bold', fontsize=11)
507
+ ax.grid(True, axis='y', linestyle='--', alpha=0.7)
 
508
  plt.tight_layout()
509
+ plt.savefig(chart_path_or_buffer, format='png', bbox_inches='tight', dpi=200)
510
+ plt.close(fig)
511
  except Exception as e:
512
  logger.error(f"Error generating chart: {str(e)}")
513
 
 
514
  # --- Acceptance Probability Calculation ---
515
  def calculate_acceptance_probability(analysis_data: Dict) -> float:
516
  """