File size: 5,258 Bytes
438c749
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c472b3c
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
import streamlit as st
from main import run_analysis
import matplotlib.pyplot as plt
from webcam_recorder import record_interview
from question_generator import generate_question
from confidence_heatmap import render_confidence_heatmap

# Page settings
st.set_page_config(
    page_title="Smart Interview Analyzer",
    layout="wide"
)

st.title("🎯 Smart Interview Analyzer")

# -------------------------
# Interview Question Generator
# -------------------------

st.subheader("🎀 Interview Question")

if st.button("Generate Interview Question"):
    question = generate_question()
    st.session_state.question = question

if "question" in st.session_state:
    st.write(st.session_state.question)

# -------------------------
# Webcam Recording
# -------------------------

st.warning("⚠️ Webcam recording is not supported in this deployment. Please upload a video instead.")
# -------------------------
# Upload Video
# -------------------------

uploaded_file = st.file_uploader("Upload Video", type=["mp4"])

if uploaded_file:

    with open("sample.mp4", "wb") as f:
        f.write(uploaded_file.read())

    st.success("Video uploaded successfully!")

    if st.button("πŸš€ Analyze Interview"):

        with st.spinner("Analyzing interview..."):
            st.session_state.results = run_analysis()

# -------------------------
# Display Results
# -------------------------

if "results" in st.session_state:

    results = st.session_state.results

    st.success("Analysis Complete!")

    # -------------------------
    # Final Score
    # -------------------------

    st.subheader("πŸ“Š Final Score")
    st.metric("Confidence Score", results["final_score"])

    # -------------------------
    # Answer Accuracy
    # -------------------------

    st.subheader("🧠 Answer Accuracy")
    st.metric("Answer Score", results["answer_score"])

    # -------------------------
    # Communication Score
    # -------------------------

    st.subheader("πŸ—£ Communication Score")
    st.metric("Communication", results["communication_score"])

    # -------------------------
    # Speech Rate
    # -------------------------

    st.subheader("⚑ Speech Rate")
    st.metric("Words per Minute", results["speech_rate"])

    # -------------------------
    # Transcript
    # -------------------------

    st.subheader("πŸ“ Transcript")
    st.write(results["text"])

    # -------------------------
    # Filler Words
    # -------------------------

    st.subheader("🚫 Filler Words")
    st.write(results["filler_count"])

    # -------------------------
    # Emotion Breakdown
    # -------------------------

    st.subheader("πŸ˜„ Emotions")
    st.write(results["emotions"])

    # -------------------------
    # Emotion Pie Chart
    # -------------------------

    st.subheader("πŸ“Š Emotion Distribution")

    emotions = results["emotions"]

    labels = list(emotions.keys())
    values = list(emotions.values())

    fig, ax = plt.subplots()
    ax.pie(values, labels=labels, autopct='%1.1f%%')

    st.pyplot(fig)

    # -------------------------
    # Confidence Trend Graph
    # -------------------------

    st.subheader("πŸ“ˆ Confidence Trend")

    timeline = results["emotion_timeline"]

    emotion_map = {
        "happy": 3,
        "neutral": 2,
        "sad": 1,
        "angry": 1,
        "fear": 1
    }

    trend_values = [emotion_map.get(e, 2) for e in timeline]

    fig2, ax2 = plt.subplots()

    ax2.plot(trend_values)
    ax2.set_ylabel("Confidence Level")
    ax2.set_xlabel("Interview Time")

    st.pyplot(fig2)

    # -------------------------
    # Confidence Heatmap
    # -------------------------

    render_confidence_heatmap(results)

    # -------------------------
    # Feedback
    # -------------------------

    st.subheader("πŸ’‘ Feedback")

    for f in results["feedback"]:
        st.write(f"β€’ {f}")

    # -------------------------
    # Grammar Analysis
    # -------------------------

    st.subheader("✍️ Grammar Analysis")

    st.metric("Grammar Score", results["grammar_score"])
    st.write("Grammar Errors:", results["grammar_errors"])

    # -------------------------
    # Keyword Relevance
    # -------------------------

    st.subheader("🎯 Keyword Relevance")

    st.metric("Keyword Score", results["keyword_score"])
    st.write("Keywords Used:", results["keyword_matches"])

    # -------------------------
    # Eye Contact
    # -------------------------

    st.subheader("πŸ‘€ Eye Contact Analysis")

    st.metric("Eye Contact Score", results["eye_contact_score"])

    st.write(
        f"Face detected in {results['face_frames']} out of {results['total_frames']} frames"
    )

    # -------------------------
    # AI Feedback
    # -------------------------

    st.subheader("πŸ€– AI Interview Feedback")

    for f in results["ai_feedback"]:
        st.write("β€’", f)

    # -------------------------
    # Topic Relevance
    # -------------------------

    st.subheader("🧠 Topic Relevance")

    st.metric("Topic Score", results["topic_score"])

    # -------------------------
    # AI Report
    # -------------------------

    st.subheader("πŸ“„ AI Interview Evaluation Report")

    st.text(results["report"])