Project Overview
The Napoleon Chat Bot is a unique fusion of historical character roleplay and modern streaming culture, creating an entertaining and interactive experience where users can converse with an AI-powered Napoleon Bonaparte who behaves like an eccentric Twitch streamer. The project combines voice interaction, text-to-speech technology, and advanced language models to create a memorable and humorous interaction.
Key Features
- Voice-activated interaction using Speech Recognition
- Dynamic text-to-speech with French accent simulation
- Integration with ElevenLabs for high-quality voice synthesis
- Fallback TTS system using pyttsx3
- Conversation history logging and playback
- Real-time responses with Twitch-inspired personality
Napoleon's Personality
- Acts like a Twitch streamer begging for subscriptions
- Mixes historical references with modern internet slang
- Paranoid about spies and conspiracies
- Randomly gives shoutouts to fictional subscribers
- Combines French phrases with English profanity
- Makes frequent references to conquering countries
Technical Implementation
Core Technologies
- Python for core application logic
- OLLAMA for AI language model integration
- ElevenLabs API for voice synthesis
- Speech Recognition for voice input
- Pygame for audio playback
- JSON for data handling
AI Components
- Custom prompt engineering for character consistency
- Context management for conversation coherence
- Dynamic temperature settings for personality variation
- Fallback systems for robust operation
Voice Processing Pipeline
The application uses a sophisticated voice processing pipeline that handles both input and output:
Input Processing
- Ambient noise adjustment
- Speech-to-text conversion
- Error handling for unclear speech
- Timeout management for user interactions
Output Generation
- Primary ElevenLabs voice synthesis
- Backup TTS system with accent simulation
- Dynamic voice parameter adjustment
- French accent simulation for backup system
Key Features Deep Dive
AI Personality System
The chatbot's personality is carefully crafted through a detailed prompt system that combines historical accuracy with modern streaming culture:
Character Traits
- Historical Napoleon's strategic mindset
- Twitch streamer mannerisms and terminology
- Integrated subscription and donation references
- Dynamic mood and response variations
Conversation Management
- Context-aware responses
- Memory of recent interactions
- Persistent conversation logging
- Interactive conversation flow
Voice Synthesis System
The project implements a robust voice synthesis system with fallback capabilities:
def text_to_speech(text, model="eleven_multilingual_v2"): try: # Primary ElevenLabs synthesis response = requests.post(url, headers=headers, data=json.dumps(data)) if response.status_code == 200: # Process and play audio else: # Fall back to backup TTS engine = pyttsx3.init() # Configure voice parameters engine.say(text) engine.runAndWait() except Exception as e: # Handle errors and use backup system print(f"Error with ElevenLabs, using backup TTS: {e}") # Initialize backup TTS
Future Enhancements
Planned Features
- Integration with Whisper for improved speech recognition
- Enhanced context management for longer conversations
- More dynamic personality variations
- Improved French accent simulation
- GUI interface for easier interaction
Technical Improvements
- Optimized model loading and response times
- Enhanced error handling and recovery
- Improved voice quality and naturalness
- Better handling of background noise