A comprehensive offline AI assistant that provides Text-to-Speech (TTS), Speech-to-Text (STT), sentiment analysis, and document analysis capabilities without requiring an internet connection.
- Text-to-Speech (TTS): Convert text to speech using pyttsx3
- Speech-to-Text (STT): Convert speech to text using speech recognition
- Sentiment Analysis: Analyze text sentiment using VADER
- Document Analysis: Analyze documents using Gensim (topic modeling, word frequency, etc.)
- 100% Offline: All processing done locally without internet dependency
- Voice Mode: Full voice interaction (TTS + STT)
- Text Mode: Text-based interaction for environments without audio
- Python 3.7 or higher
- Windows 10/11, macOS, or Linux
- Microphone and speakers (for voice mode)
- At least 2GB RAM
- 500MB free disk space
- pyttsx3 (TTS)
- SpeechRecognition (STT)
- PyAudio (Audio processing)
- vaderSentiment (Sentiment analysis)
- gensim (Document analysis)
- numpy, scipy (Numerical processing)
git clone <repository-url>
cd offline-ai-assistantpip install -r requirements.txt- PyAudio should install automatically
- TTS uses Windows SAPI voices
- No additional setup required
# Install portaudio (required for PyAudio)
brew install portaudio
# Install dependencies
pip install -r requirements.txt# Install system dependencies
sudo apt-get update
sudo apt-get install python3-pyaudio portaudio19-dev espeak-ng
# Install Python dependencies
pip install -r requirements.txt# Install system dependencies
sudo yum install portaudio-devel espeak-ng
# or for Fedora: sudo dnf install portaudio-devel espeak-ng
# Install Python dependencies
pip install -r requirements.txtpython main.pyThe assistant will prompt you to choose between:
- Voice Mode: Full voice interaction
- Text Mode: Text-based interaction
hello/hi- Greetingtime- Get current timedate- Get current datehelp- Show available commandsexit/quit- Close the assistant
sentimentoranalyze- Analyze text sentiment- The assistant will prompt you to enter text for analysis
documentoranalyze document- Analyze document content- The assistant will prompt you to enter text for analysis
You can modify TTS settings in the initialize_tts() method:
- Speech rate (default: 150)
- Volume level (default: 0.9)
- Voice selection
Adjust STT parameters in the initialize_stt() method:
- Energy threshold (default: 4000)
- Dynamic energy threshold (default: True)
- Pause threshold (default: 0.8)
Modify audio parameters in the __init__ method:
- Sample rate (default: 44100 Hz)
- Channels (default: 1)
- Chunk size (default: 1024)
- Engine: pyttsx3 with system TTS backends
- Voices: Automatically selects best available voice
- Customization: Adjustable speed and volume
- Languages: Supports multiple languages based on system voices
- Engine: SpeechRecognition with Google's speech recognition
- Noise Reduction: Automatic ambient noise adjustment
- Timeout Handling: Configurable listening timeouts
- Error Handling: Graceful fallback for recognition failures
- Engine: VADER (Valence Aware Dictionary and sEntiment Reasoner)
- Features:
- Positive, negative, and neutral sentiment scores
- Compound sentiment score (-1 to +1)
- Sentiment categorization
- Use Cases: Social media analysis, customer feedback, content analysis
- Engine: Gensim
- Features:
- Topic modeling (LDA)
- Word frequency analysis
- Key topic extraction
- Document statistics
- Use Cases: Content analysis, document clustering, topic discovery
- Check if system has TTS voices installed
- On Linux, install espeak-ng:
sudo apt-get install espeak-ng - Verify pyttsx3 installation:
pip show pyttsx3
- Check microphone permissions
- Verify PyAudio installation:
pip show PyAudio - On Linux, install portaudio:
sudo apt-get install portaudio19-dev
- Ensure all dependencies are installed:
pip install -r requirements.txt - Check Python version:
python --version - Verify virtual environment if using one
- Adjust microphone settings in system preferences
- Modify audio parameters in the code
- Check audio drivers and hardware
- Reduce TTS speech rate for better clarity
- Adjust STT energy threshold for your environment
- Use text mode for faster processing without audio
- 100% Offline: No data sent to external services
- Local Processing: All analysis done on your device
- No Logging: Optional logging can be disabled
- Secure: No network communication required
The assistant creates log files for debugging:
- File:
ai_assistant.log - Console: Real-time logging to terminal
- Level: INFO by default
To disable logging, modify the setup_logging() method.
Contributions are welcome! Areas for improvement:
- Additional TTS engines
- More STT options
- Enhanced sentiment analysis
- Better document analysis algorithms
- UI improvements
- Performance optimizations
This project is open source. Please check the license file for details.
- pyttsx3: Cross-platform TTS library
- SpeechRecognition: Speech recognition library
- VADER: Sentiment analysis tool
- Gensim: Topic modeling and document analysis
- PyAudio: Audio processing library
For issues and questions:
- Check the troubleshooting section
- Review the logs in
ai_assistant.log - Verify all dependencies are installed
- Check system audio settings
Note: This assistant is designed to work completely offline. For best results, ensure your system has good quality TTS voices and a working microphone.