asmithaaa's picture
Update app.py
c472b3c verified
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"])