Skip to content

AdityaGaur7/FightAi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

9 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– AI Debate Simulator

A web application that simulates dynamic debates between two AI agents with distinct personalities - one aggressive (PROS) and one analytical (CONS) - using Google's Gemini API. Users can select topics and experience realistic debate conversations with human-like text-to-speech capabilities. Screenshot 2025-09-05 233144

Debate.mp4

Features

  • ๐ŸŽฏ Topic Selection: Choose from predefined topics or create custom ones
  • ๐ŸŽญ Dual Personalities: PROS (aggressive) vs CONS (analytical) AI agents
  • ๐Ÿ”Š Text-to-Speech: Human-like voices with male (PROS) and female (CONS) voices
  • ๐ŸŽฎ Interactive Controls: Adjust debate rounds and playback controls
  • ๐Ÿ“ฑ Responsive Design: Works on desktop and mobile devices
  • ๐ŸŽจ Modern UI: Beautiful gradient design with smooth animations
  • ๐Ÿ”„ Real-time Generation: Dynamic debate creation with streaming responses

Prerequisites

  • Python 3.8+
  • Node.js 20.19+ (for building the frontend)
  • Google Gemini API key
  • ElevenLabs API key (optional, for enhanced voice quality)

Setup Instructions

1. Clone and Navigate

cd Yxth

2. Set up Python Environment

# Create virtual environment (if not already created)
python -m venv venv

# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate

# Install Python dependencies
pip install -r requirements.txt

3. Set up Frontend

cd client
npm install
npm run build
cd ..

4. Configure API Keys

Create a .env file in the root directory:

GOOGLE_API_KEY=your_gemini_api_key_here
ELEVENLABS_API_KEY=your_elevenlabs_api_key_here

You can get a Gemini API key from Google AI Studio. You can get an ElevenLabs API key from ElevenLabs (optional).

Running the Application

Start the Server

python main.py

The application will be available at http://localhost:5000

How to Use

  1. Select a Topic: Choose from the predefined topics or create a custom one
  2. Adjust Rounds: Use the slider to set the number of debate rounds (1-5)
  3. Generate Debate: Click "Generate Conversation" to create the debate
  4. Listen: Click "Play Conversation" to hear the agents speak with different voices
  5. Control Playback: Use the stop button to halt the conversation at any time

Technical Details

Backend (Python/Flask)

  • Framework: Flask with CORS support
  • AI Model: Google Gemini 2.0 Flash
  • API Endpoints:
    • /api/conversation (POST) - Generate debate
    • /api/generate-and-speak (POST) - Stream debate with TTS
  • Features: Dynamic debate generation with personality prompts and streaming responses

Frontend (React/TypeScript)

  • Framework: React 19 with TypeScript
  • Styling: Custom CSS with modern gradients and animations
  • Text-to-Speech: Web Speech API with voice selection
  • Responsive: Mobile-first design approach
  • Build Tool: Vite for fast development and optimized builds

AI Personalities

  • PROS Agent: Speaks with passion and conviction, highlighting opportunities and benefits
  • CONS Agent: Maintains a critical, analytical tone, revealing risks and drawbacks
  • Context Awareness: Both agents respond to each other's arguments in real-time

Voice Configuration

  • PROS Agent: Male voice with higher pitch and faster rate
  • CONS Agent: Female voice with lower pitch and normal rate
  • Enhanced TTS: Optional ElevenLabs integration for premium voice quality
  • Fallback: Uses available English voices if specific voices aren't found

API Response Format

{
  "success": true,
  "conversation": [
    {
      "speaker": "pros",
      "text": "That's an excellent point! Technology is clearly revolutionizing how we work...",
      "round": 1
    },
    {
      "speaker": "cons",
      "text": "I understand your enthusiasm, but let me point out some critical concerns...",
      "round": 1
    }
  ],
  "topic": "Is technology making humans lazy?"
}

Customization

Adding New Topics

Edit the predefinedTopics array in client/src/App.tsx:

const predefinedTopics = [
  "Your new debate topic here?",
  // ... existing topics
];

Modifying Personalities

Update the personality prompts in main.py:

pros_prefix = "Your custom PROS personality prompt..."
cons_prefix = "Your custom CONS personality prompt..."

Voice Settings

Adjust voice parameters in client/src/App.tsx:

utterance.rate = 0.9; // Speech rate (0.1 to 10)
utterance.pitch = 1.1; // Pitch (0 to 2)
utterance.volume = 1; // Volume (0 to 1)

Troubleshooting

Common Issues

  1. API Key Error: Ensure your .env file contains a valid Gemini API key
  2. Voice Not Working: Check if your browser supports the Web Speech API
  3. CORS Errors: Make sure the Flask server is running on port 5000
  4. Build Errors: Ensure Node.js version is 20.19+ for Vite compatibility
  5. Streaming Issues: Check network connectivity for real-time debate generation

Browser Compatibility

  • Chrome/Edge: Full support with best TTS experience
  • Firefox: Limited TTS support
  • Safari: Limited TTS support

Project Structure

Yxth/
โ”œโ”€โ”€ client/                 # React frontend
โ”‚   โ”œโ”€โ”€ src/               # Source code
โ”‚   โ”œโ”€โ”€ dist/              # Built frontend
โ”‚   โ””โ”€โ”€ package.json       # Frontend dependencies
โ”œโ”€โ”€ main.py                # Flask backend server
โ”œโ”€โ”€ requirements.txt        # Python dependencies
โ”œโ”€โ”€ .env                   # Environment variables
โ””โ”€โ”€ README.md              # This file

License

This project is open source and available under the MIT License.

Contributing

Feel free to submit issues and enhancement requests! Contributions are welcome for:

  • New debate topics
  • Personality improvements
  • UI/UX enhancements
  • Performance optimizations

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors