Spaces:
Sleeping
Sleeping
| 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"]) |