Spaces:
Sleeping
Sleeping
Fix missing configuration in README.md and update content
Browse files- process_interview.py +18 -17
process_interview.py
CHANGED
|
@@ -23,6 +23,8 @@ from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, Tabl
|
|
| 23 |
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
|
| 24 |
from reportlab.lib.units import inch
|
| 25 |
from reportlab.lib import colors
|
|
|
|
|
|
|
| 26 |
# --- End Imports for enhanced PDF ---
|
| 27 |
from transformers import AutoTokenizer, AutoModel
|
| 28 |
import spacy
|
|
@@ -482,28 +484,27 @@ def generate_voice_interpretation(analysis: Dict) -> str:
|
|
| 482 |
|
| 483 |
|
| 484 |
# --- Chart Generation Function ---
|
| 485 |
-
# Removed function as charts are no longer included
|
| 486 |
def generate_anxiety_confidence_chart(composite_scores: Dict, chart_path: str):
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
scores = [composite_scores.get('anxiety', 0), composite_scores.get('confidence', 0)]
|
| 491 |
|
| 492 |
-
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
|
| 498 |
for i, v in enumerate(scores):
|
| 499 |
-
|
| 500 |
ax.text(i, v + 0.05, f"{v:.2f}", color='black', ha='center', fontweight='bold')
|
| 501 |
|
| 502 |
-
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
|
|
|
|
|
|
|
| 507 |
|
| 508 |
|
| 509 |
# --- Acceptance Probability Calculation ---
|
|
@@ -645,7 +646,7 @@ def generate_report(analysis_data: Dict) -> str:
|
|
| 645 |
return f"Error generating report: {str(e)}"
|
| 646 |
|
| 647 |
|
| 648 |
-
# --- ENHANCED PDF GENERATION FUNCTION
|
| 649 |
def create_pdf_report(analysis_data: Dict, output_path: str, gemini_report_text: str):
|
| 650 |
try:
|
| 651 |
doc = SimpleDocTemplate(output_path, pagesize=letter)
|
|
|
|
| 23 |
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
|
| 24 |
from reportlab.lib.units import inch
|
| 25 |
from reportlab.lib import colors
|
| 26 |
+
import matplotlib.pyplot as plt # تم تفعيله
|
| 27 |
+
from reportlab.platypus import Image # تم تفعيله
|
| 28 |
# --- End Imports for enhanced PDF ---
|
| 29 |
from transformers import AutoTokenizer, AutoModel
|
| 30 |
import spacy
|
|
|
|
| 484 |
|
| 485 |
|
| 486 |
# --- Chart Generation Function ---
|
|
|
|
| 487 |
def generate_anxiety_confidence_chart(composite_scores: Dict, chart_path: str):
|
| 488 |
+
try:
|
| 489 |
+
labels = ['Anxiety', 'Confidence']
|
| 490 |
+
scores = [composite_scores.get('anxiety', 0), composite_scores.get('confidence', 0)]
|
|
|
|
| 491 |
|
| 492 |
+
fig, ax = plt.subplots(figsize=(4, 2.5)) # Smaller size for embedding in PDF
|
| 493 |
+
ax.bar(labels, scores, color=['lightcoral', 'lightskyblue'])
|
| 494 |
+
ax.set_ylabel('Score')
|
| 495 |
+
ax.set_title('Anxiety vs. Confidence Scores')
|
| 496 |
+
ax.set_ylim(0, 1.0) # Assuming scores are normalized 0-1
|
| 497 |
|
| 498 |
for i, v in enumerate(scores):
|
|
|
|
| 499 |
ax.text(i, v + 0.05, f"{v:.2f}", color='black', ha='center', fontweight='bold')
|
| 500 |
|
| 501 |
+
# هذه الأوامر يجب أن تكون خارج الـ loop عشان يتم تنفيذها مرة واحدة بعد رسم كل العناصر
|
| 502 |
+
plt.tight_layout()
|
| 503 |
+
plt.savefig(chart_path)
|
| 504 |
+
plt.close(fig) # Close the figure to free up memory
|
| 505 |
+
except Exception as e:
|
| 506 |
+
logger.error(f"Error generating chart: {str(e)}")
|
| 507 |
+
# You might want to create a placeholder image or simply log the error
|
| 508 |
|
| 509 |
|
| 510 |
# --- Acceptance Probability Calculation ---
|
|
|
|
| 646 |
return f"Error generating report: {str(e)}"
|
| 647 |
|
| 648 |
|
| 649 |
+
# --- ENHANCED PDF GENERATION FUNCTION ---
|
| 650 |
def create_pdf_report(analysis_data: Dict, output_path: str, gemini_report_text: str):
|
| 651 |
try:
|
| 652 |
doc = SimpleDocTemplate(output_path, pagesize=letter)
|