Skip to content

hrranger5/Trivia-Host-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Trivia Host: An AI-Powered Conversational Game

Step into a new era of trivia with Trivia Host, an interactive web application where you compete against a dynamic AI. Choose your host's personality, answer challenging questions using your voice, and experience a truly personalized trivia game, all powered by the Google Gemini API.

✨ Features

  • Dynamic AI Personalities: Choose from a variety of unique hosts, such as a "Sarcastic Robot" or a "Mysterious Wizard," each with their own style of asking questions and giving feedback.
  • Voice-Activated Answers: No typing required! Simply hold the microphone button and speak your answer.
  • Real-time, Grounded Questions: The AI generates fresh trivia questions on random topics, using Google Search grounding to ensure accuracy and timeliness.
  • Conversational Feedback: The AI host provides in-character feedback, tells you if you're correct, and shares interesting facts related to the questions.
  • Text-to-Speech Output: Hear your host's personality come to life as it speaks the questions and its witty responses.
  • Session History: Track your progress with a detailed history of past games, including your final score, all questions, and your answers. Data is saved locally in your browser.
  • Sleek, Modern UI: A responsive and futuristic interface built with Angular and Tailwind CSS.

🤖 How It Works

The application creates a seamless, conversational trivia experience through a series of interactions with the Gemini API and browser features.

  1. Personality Selection: The user chooses a personality for the AI host.
  2. Question Generation: The frontend calls the Gemini API (gemini-2.5-flash) with a prompt that includes the chosen personality. It requests a structured JSON object for a trivia question and uses Google Search grounding to pull from up-to-date information.
  3. Voice Input: The user holds the microphone button to record their answer using the browser's MediaRecorder API.
  4. Answer Evaluation: The recorded audio is sent to the Gemini API as a base64 string. The API transcribes the speech, evaluates if the answer is correct against the provided context, and generates a conversational response in the host's personality.
  5. Audio Feedback: The host's response text is spoken back to the user via the browser's Web Speech API (Text-to-Speech).
  6. History Persistence: When a game is finished, the entire session (personality, score, and all rounds) is saved to the browser's localStorage for future review.

🛠️ Tech Stack

  • Framework: Angular (v20+, Zoneless, Standalone Components)
  • State Management: Angular Signals
  • AI/LLM: Google Gemini API (@google/genai)
  • Styling: Tailwind CSS
  • Browser APIs:
    • Web Speech API (SpeechSynthesis for Text-to-Speech)
    • MediaStream API (for microphone input)

🚀 Running the Project

This application is designed to run in a modern web browser that supports the required Web APIs.

API Key Configuration

The application requires a Google Gemini API key to function. It is configured to read the key from an environment variable:

process.env.API_KEY

Ensure this variable is available in the execution environment when the application is run.

Releases

Packages

Contributors

Languages