CoolFace
Apppublic

MOSES3377/ai-interview-app

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
App README

๐Ÿค– AI Interviewer Project

This is a complete, production-ready AI Interview Project built with Python and Gradio. The application conducts a simulated job interview where an AI asks questions via voice, listens to the candidate's spoken responses, transcribes them, and provides an evaluation and summary at the end.

โœจ Features

  • โ€”Dynamic Question Generation: Uses OpenAI's GPT models to generate relevant interview questions based on the specified job role.
  • โ€”Voice-based Interaction: The AI asks questions using Text-to-Speech (TTS), and the candidate answers by speaking into their microphone.
  • โ€”Live Transcription: Candidate's spoken answers are transcribed in real-time using OpenAI's Whisper API.
  • โ€”AI-Powered Evaluation: Each answer is evaluated by an LLM, which provides a score (0-10) and constructive feedback.
  • โ€”Live Webcam Monitoring: The candidate's webcam is active during the interview for proctoring simulation.
  • โ€”Final Summary: At the end of the interview, a comprehensive summary and an average score are provided.
  • โ€”Modular & Extensible: The codebase is organized into modules for LLM, STT, and TTS utilities, making it easy to extend or swap components.
  • โ€”Deployable: Ready to be deployed as a Gradio App on Hugging Face Spaces.

๐Ÿ“‚ Project Structure

.
โ”œโ”€โ”€ app.py              # Main Gradio application entrypoint
โ”œโ”€โ”€ llm_utils.py        # Utilities for OpenAI LLM interaction (questions, evaluation)
โ”œโ”€โ”€ stt_utils.py        # Utilities for Speech-to-Text (Whisper API)
โ”œโ”€โ”€ tts_utils.py        # Utilities for Text-to-Speech (gTTS)
โ”œโ”€โ”€ questions.json      # Fallback static question bank
โ”œโ”€โ”€ requirements.txt    # Python dependencies
โ”œโ”€โ”€ .gitignore          # Files to be ignored by Git
โ””โ”€โ”€ README.md           # This file

โš™๏ธ Setup and Installation (Local)

Follow these steps to set up and run the project on your local machine.

1. Prerequisites

  • โ€”Python 3.8+
  • โ€”FFmpeg: This is a critical dependency required by the pydub library to process audio files.
  • โ€”On macOS (using Homebrew):
bash
    brew install ffmpeg
  • โ€”On Ubuntu/Debian:
bash
    sudo apt update && sudo apt install ffmpeg
  • โ€”On Windows: Download the binaries from the official FFmpeg website, extract them, and add the bin directory to your system's PATH environment variable.

2. Clone the Repository

bash
git clone <repository_url>
cd ai-interviewer-project

3. Create a Virtual Environment

It's highly recommended to use a virtual environment to manage dependencies.

bash
python -m venv venv
# On Windows
venv\Scripts\activate
# On macOS/Linux
source venv/bin/activate

4. Install Dependencies

Install all the required Python packages from requirements.txt.

bash
pip install -r requirements.txt

5. Set Up Environment Variables

You need an OpenAI API key to use the LLM and Whisper models.

  1. 1.Create a file named .env in the root directory of the project.
  2. 2.Add your OpenAI API key to this file:
    OPENAI_API_KEY="sk-YourSecretOpenAIKeyGoesHere"
    # Optional: Specify a different model
    # OPENAI_MODEL="gpt-4"

๐Ÿš€ Running the Application

Once the setup is complete, you can run the Gradio application with a single command:

bash
python app.py

This will start a local web server. Open the URL provided in the terminal (usually http://127.0.0.1:7860) in your web browser to start the interview.

๐ŸŒ Deployment to Hugging Face Spaces

This application is designed to be easily deployed on Hugging Face Spaces.

  1. 1.Create a Hugging Face Account: If you don't have one, sign up at huggingface.co.
  1. 1.Create a New Space:
  2. 2.Click on your profile picture and select "New Space".
  3. 3.Give your Space a name (e.g., ai-interviewer).
  4. 4.Select "Gradio" as the Space SDK.
  5. 5.Choose a hardware configuration (the free CPU tier is sufficient to start).
  6. 6.Click "Create Space".
  1. 1.Upload Project Files:
  2. 2.You can upload your files directly via the web interface or by cloning the repository created for your Space and pushing your code via Git.
  3. 3.Make sure you upload all the files: app.py, llm_utils.py, stt_utils.py, tts_utils.py, questions.json, and requirements.txt.
  1. 1.Add Your API Key as a Secret:
  2. 2.Do not upload your .env file or hardcode your API key.
  3. 3.In your Hugging Face Space, go to the "Settings" tab.
  4. 4.Scroll down to "Repository secrets".
  5. 5.Click "New secret".
  6. 6.For the Name, enter OPENAI_API_KEY.
  7. 7.For the Value, paste your actual OpenAI API key (sk-...).
  8. 8.Click "Save secret".

The Space will automatically detect your requirements.txt file, install the dependencies, and run app.py. Your AI Interviewer will now be live and accessible to anyone with the link!