A conversational AI application designed to help users practice for the US Naturalization Test. The app simulates a verbal interview experience using AI-generated questions and feedback.
- Conversational Interface: Uses OpenAI's GPT-4o to act as a practice examiner.
- Voice Interaction: Includes Text-to-Speech (TTS) for asking questions and Speech-to-Text (STT) for capturing user answers.
- Real-time Feedback: Provides immediate correction and explanation for answers.
- Audio Visualization: Visual feedback during listening and speaking phases.
- Node.js (v18+ recommended)
- OpenAI API Key
-
Clone the repository:
git clone https://github.com/jGiltinan/Citizen_Quiz.git cd Citizen_Quiz -
Install dependencies:
npm install
-
Set up environment variables: Create a
.envfile in the root directory and add your OpenAI API key and Vector Store ID:OPENAI_API_KEY=your_api_key_here OPENAI_VECTOR_STORE_ID=your_vector_store_id_here
Note: This app requires an OpenAI Vector Store containing the US Naturalization Test questions (PDF/Text).
To make this app work, you need to provide it with the knowledge base (the test questions).
-
Prepare your document: Download the 100 Civics Questions (PDF) or create a text file with the questions.
-
Go to OpenAI Platform: Navigate to the Vector Stores dashboard.
-
Create New Store: Click "+ Create", name it (e.g., "Citizen Quiz"), and upload your document.
-
Get the ID: Copy the
ID(starts withvs_...) and paste it into your.envfile asOPENAI_VECTOR_STORE_ID. -
Run the development server:
npm run dev
-
Open http://localhost:3000 with your browser.
Special attention has been given to support iOS devices (iPhone/iPad), which have strict policies regarding audio autoplay and microphone usage.
- Audio Unlock: The app plays a silent sound immediately upon "Start Quiz" to unlock the audio context for Safari.
- Robust Recording: The app acquires a fresh microphone stream for every question to maintain stability on iOS.
- Fallback Mode: If audio playback fails or the network is slow, the app includes a fallback to the device's system voice (SpeechSynthesis) to ensure the quiz can continue.
Warning
Known Issue (Non-iOS Devices): The "fresh stream" logic implemented for iOS stability may cause regressions or instability on some Android or Desktop browsers. If you experience microphone issues on non-Apple devices, consider refreshing the page.
- Framework: Next.js
- AI/LLM: OpenAI GPT-4o (Assistant API/Chat Completions)
- Audio: OpenAI TTS & Whisper (for transcription)
- Styling: Tailwind CSS, Framer Motion
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.