File size: 3,447 Bytes
438c749
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
from grammar_analysis import grammar_score
from video_processing import extract_frames
from audio_extraction import extract_audio
from speech_to_text import transcribe_audio
from filler_detection import count_filler_words
from emotion_detection import analyze_emotions
from scoring import calculate_emotion_score, calculate_filler_score, final_score
from answer_analysis import calculate_answer_similarity
from scoring import communication_score
from speech_analysis import speech_rate
from keyword_analysis import keyword_score
from eye_contact_analysis import eye_contact_score
from feedback_generator import generate_feedback
from topic_analysis import topic_relevance
from report_generator import generate_interview_report

def run_analysis():
    # Step 1: Extract frames
    extract_frames("sample.mp4")

    # Step 2: Extract audio
    extract_audio("sample.mp4")

    # Step 3: Speech to text
    text = transcribe_audio("output/audio.wav")

    keyword, keyword_matches = keyword_score(text)

    grammar, grammar_errors = grammar_score(text)

    # Step 4: Filler detection
    filler_count = count_filler_words(text)

    # Step 5: Emotion detection
    emotion_counts, emotion_timeline = analyze_emotions()

    eye_score, face_frames, total_frames = eye_contact_score()

    # Step 6: Scores
    emotion_score = calculate_emotion_score(emotion_counts)
    filler_score = calculate_filler_score(filler_count, text)

    answer_score = calculate_answer_similarity(
        text,
        "Python is a high-level programming language used for web development, data science, and automation."
    )

    comm_score = communication_score(text)

    rate = speech_rate("output/audio.wav", text)

    topic_score = topic_relevance(text, "Explain Python programming language")

    feedback = []

    if filler_count > 5:
        feedback.append("Reduce filler words")

    if emotion_score < 50:
        feedback.append("Improve facial expressions")

    if answer_score < 60:
        feedback.append("Improve answer quality")

    if comm_score < 60:
        feedback.append("Improve communication clarity")

    if not feedback:
        feedback.append("Excellent performance!")

    final = final_score(emotion_score, filler_score)

    feedback_report = generate_feedback({
    "grammar_score": grammar,
    "filler_count": filler_count,
    "speech_rate": rate,
    "eye_contact_score": eye_score,
    "answer_score": answer_score,
    
})
    report = generate_interview_report({
    "final_score": final,
    "speech_rate": rate,
    "grammar_score": grammar,
    "eye_contact_score": eye_score,
    "answer_score": answer_score,
    "filler_count": filler_count,
    "topic_score": topic_score
})

    return {
    "text": text,
    "filler_count": filler_count,
    "emotions": emotion_counts,
    "emotion_score": emotion_score,
    "emotion_timeline": emotion_timeline,
    "filler_score": filler_score,
    "answer_score": answer_score,
    "communication_score": comm_score,
    "speech_rate": rate,
    "grammar_score": grammar,
    "grammar_errors": grammar_errors,
    "keyword_score": keyword,
    "keyword_matches": keyword_matches,
    "eye_contact_score": eye_score,
    "face_frames": face_frames,
    "total_frames": total_frames,
    "final_score": final,
    "feedback": feedback,
    "ai_feedback": feedback_report,
    "topic_score": topic_score,
    "report": report
}

if __name__ == "__main__":
    run_analysis()