Build This Project · AI Portfolio
AI Interview Preparation Agent — Complete Project Guide
Quick summary — build an AI interview preparation agent
Interview preparation is a perfect AI application. This project demonstrates your ability to build an AI agent that conducts mock interviews, evaluates answers, and provides actionable feedback — a complete AI system.
In this guide you will learn:
- Project overview — what you'll build and why.
- Question generation — using LLMs for interview questions.
- Speech-to-text integration — voice interaction.
- Answer evaluation — AI-powered feedback.
- Building the app — Streamlit interface.
- Portfolio presentation — how to show it to employers.
SECTION 01Project overview
Here's what you'll build in this project:
- Business problem: Job seekers need practice answering interview questions and getting feedback on their responses.
- Your solution: An AI agent that generates interview questions, listens to answers (or accepts text), and provides detailed feedback.
- Tools: Python, OpenAI/Claude API, Whisper API, Streamlit.
- Outcome: A portfolio-ready AI application that demonstrates LLM integration, speech processing, and AI feedback.
SECTION 02Question generation
Here's how to generate interview questions using LLMs:
import openai
def generate_questions(role, num_questions=5):
prompt = f"""Generate {num_questions} interview questions for a {role} position.
Include a mix of behavioral, technical, and situational questions.
Questions:
1. """
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": prompt}]
)
questions = response.choices[0].message.content.strip().split('\n')
questions = [q.strip() for q in questions if q.strip()]
return questions
# Example
questions = generate_questions("Data Analyst")
for i, q in enumerate(questions):
print(f"{i+1}. {q}")
# Question templates for different roles
question_templates = {
"Data Analyst": [
"Tell me about a time you used data to solve a business problem.",
"How do you approach cleaning messy data?",
"Explain a dashboard you built and its impact.",
"Describe your experience with SQL and Python.",
"How do you communicate insights to non-technical stakeholders?"
],
"Software Engineer": [
"Explain a complex technical problem you solved.",
"How do you approach debugging?",
"Describe your experience with system design.",
"How do you stay updated with new technologies?",
"Tell me about a project you led."
]
}
def get_template_questions(role):
return question_templates.get(role, question_templates["Data Analyst"])
SECTION 03Speech-to-text integration
Here's how to integrate speech-to-text for voice answers:
import openai
def transcribe_audio(audio_file):
with open(audio_file, "rb") as f:
response = openai.Audio.transcribe(
model="whisper-1",
file=f
)
return response["text"]
# Alternative: Use local Whisper model
# import whisper
# model = whisper.load_model("base")
# result = model.transcribe("audio.wav")
# print(result["text"])
# Record audio from microphone
import sounddevice as sd
import soundfile as sf
def record_audio(duration=10, sample_rate=16000):
print(f"Recording for {duration} seconds...")
recording = sd.rec(int(duration * sample_rate), samplerate=sample_rate, channels=1)
sd.wait()
sf.write("recording.wav", recording, sample_rate)
print("Recording saved.")
return "recording.wav"
# Usage in app
def get_voice_answer():
audio_file = record_audio(duration=30)
text = transcribe_audio(audio_file)
return text
SECTION 04Answer evaluation
Here's how to evaluate interview answers:
def evaluate_answer(question, answer):
prompt = f"""Evaluate this interview answer.
Question: {question}
Answer: {answer}
Provide:
1. A score from 1-10
2. Strengths of the answer
3. Areas for improvement
4. A sample improved answer
Format your response as a structured evaluation."""
response = openai.ChatCompletion.create(
model="gpt-4",
messages=[{"role": "user", "content": prompt}]
)
return response.choices[0].message.content
# Example
question = "Tell me about a time you used data to solve a business problem."
answer = "I used SQL to analyze customer data and found a trend..."
feedback = evaluate_answer(question, answer)
print(feedback)
# Structured feedback template
def get_feedback(question, answer):
evaluation = evaluate_answer(question, answer)
# Parse evaluation into structured format
feedback = {
"score": extract_score(evaluation),
"strengths": extract_strengths(evaluation),
"improvements": extract_improvements(evaluation),
"sample_answer": extract_sample(evaluation)
}
return feedback
def extract_score(evaluation):
# Extract score from evaluation text
import re
match = re.search(r'Score:?\s*(\d+)/10', evaluation)
if match:
return int(match.group(1))
return 7 # default
# Helper functions for parsing
def extract_strengths(evaluation):
# Extract strengths section
pass
def extract_improvements(evaluation):
# Extract areas for improvement
pass
SECTION 05Building the app
Here's how to build the Streamlit app:
import streamlit as st
st.title("AI Interview Preparation Agent")
# Sidebar for settings
st.sidebar.title("Settings")
role = st.sidebar.selectbox("Select Role", ["Data Analyst", "Software Engineer", "Data Scientist"])
question_type = st.sidebar.radio("Question Type", ["Technical", "Behavioral", "Mixed"])
# Initialize session state
if 'questions' not in st.session_state:
st.session_state.questions = []
if 'current_q' not in st.session_state:
st.session_state.current_q = 0
# Generate questions
if st.button("Start Interview"):
st.session_state.questions = generate_questions(role)
st.session_state.current_q = 0
st.session_state.answers = []
# Interview loop
if st.session_state.questions:
q_index = st.session_state.current_q
if q_index < len(st.session_state.questions):
st.subheader(f"Question {q_index + 1}")
st.write(st.session_state.questions[q_index])
# Input methods
input_method = st.radio("How would you like to answer?", ["Text", "Voice"])
if input_method == "Voice":
if st.button("Record Answer"):
with st.spinner("Recording..."):
answer = get_voice_answer()
st.write(f"Your answer: {answer}")
st.session_state.answer = answer
else:
answer = st.text_area("Your answer:")
# Submit and evaluate
if st.button("Submit Answer"):
if 'answer' in locals():
feedback = evaluate_answer(st.session_state.questions[q_index], answer)
st.session_state.feedback = feedback
st.session_state.answers.append(answer)
st.session_state.current_q += 1
elif st.session_state.get('answer'):
feedback = evaluate_answer(st.session_state.questions[q_index], st.session_state.answer)
st.session_state.feedback = feedback
st.session_state.answers.append(st.session_state.answer)
st.session_state.current_q += 1
else:
# End of interview
st.success("🎉 Interview Complete!")
st.subheader("Your Answers")
for i, ans in enumerate(st.session_state.answers):
with st.expander(f"Question {i+1}"):
st.write(st.session_state.questions[i])
st.write("Your answer:", ans)
if st.button("Get Overall Feedback"):
overall = evaluate_overall(st.session_state.questions, st.session_state.answers)
st.write(overall)
# Deploy on Streamlit Cloud
# Requirements:
# streamlit, openai, sounddevice, soundfile, whisper
# Environment variables:
# OPENAI_API_KEY
# Run:
# streamlit run app.py
SECTION 06Portfolio presentation
Here's how to present this project to employers:
- GitHub: Upload your code, LLM integration, and app code.
- README: Write a clear README with project overview, features, and deployment instructions.
- Live demo: Deploy your app on Streamlit Cloud.
- Screenshots: Add screenshots of your app in action.
- LinkedIn post: Share your project with a brief explanation of the problem you solved.
SECTION 07Interview Q&A — AI interview agent
Q1Why did you choose an interview preparation agent?
Interview preparation is a real problem for job seekers. I wanted to show I can build AI agents that solve practical problems and help people.
Q2What LLM did you use?
I used OpenAI's GPT-4 for question generation and answer evaluation. I also used Whisper for speech-to-text.
Q3How does the agent evaluate answers?
The agent uses GPT-4 to evaluate answers based on clarity, completeness, structure, and relevance. It provides a score and improvement suggestions.
Q4What was the biggest challenge?
Generating realistic interview questions and evaluating answers consistently was the biggest challenge.
Q5What would you do differently next time?
I'd add a database of sample answers, industry-specific questions, and a progress tracking feature.
SECTION 08Test yourself — interview agent quiz
Five questions. No sign-up.
0 / 5Pick an answer to see why it is right or wrong.
SECTION 09Frequently asked questions
What's the best LLM for interview question generation?
GPT-4 and Claude are both excellent. GPT-3.5 is also good for simpler applications.
How does the speech-to-text work?
I used OpenAI's Whisper API to transcribe audio recordings into text for evaluation.
Can the agent handle different roles?
Yes — you can customize questions for different roles by changing the prompt or using role-specific templates.
How long does this project take?
3-4 weeks — 1 week for question generation, 1 week for speech integration, 1 week for evaluation, 1 week for app and deployment.
Do I need an OpenAI API key?
Yes — for the LLM and Whisper API. You can also use open-source alternatives if you prefer.
SECTION 10Related reads
Classroom & online · Noida
Build AI agent projects — get hired
Our Artificial Intelligence Training Course includes AI agent and other AI projects with step-by-step guidance.
₹18,500 · full programme- 8 AI projects
- LLM integration
- Mock interviews
- Weekday & weekend batches