🔧 TimeCraft AI - Installation and Configuration Guide¶
📋 Prerequisites¶
Operating System¶
- ✅ Linux (Ubuntu/Debian recommended)
- ✅ macOS
- ✅ Windows 10/11
Python¶
- Python 3.8+ (recommended: 3.10+)
- Updated pip
Hardware¶
- 🎤 Functional microphone
- 🔊 Speakers or headphones
- 💾 At least 2GB of free space (for voice models)
🚀 Quick Installation¶
1. Clone the repository¶
2. Create virtual environment¶
3. Install dependencies¶
4. Download voice model (Vosk)¶
# Portuguese (recommended)
mkdir -p models
cd models
wget https://alphacephei.com/vosk/models/vosk-model-small-pt-0.3.zip
unzip vosk-model-small-pt-0.3.zip
mv vosk-model-small-pt-0.3 vosk-model-small-pt
cd ..
5. Configure Picovoice key (optional)¶
6. Test installation¶
🎤 Audio Configuration¶
Linux (Ubuntu/Debian)¶
# Install audio dependencies
sudo apt-get update
sudo apt-get install -y portaudio19-dev python3-pyaudio alsa-utils
# Test microphone
arecord -l # List recording devices
aplay -l # List playback devices
# Adjust volume
alsamixer
macOS¶
# Install PortAudio via Homebrew
brew install portaudio
# Check microphone permissions
# Go to: System Preferences > Security & Privacy > Privacy > Microphone
# Add your terminal/IDE to the list
Windows¶
# Install Microsoft C++ Build Tools if needed
# Download from: https://visualstudio.microsoft.com/visual-cpp-build-tools/
# Check audio devices
# Control Panel > Sound > Recording/Playback
🔧 Troubleshooting¶
❌ Error: “No module named ‘pyaudio’”¶
# Linux
sudo apt-get update && sudo apt-get install -y portaudio19-dev
pip install pyaudio
# Windows
pip install pipwin
pipwin install pyaudio
# macOS
brew install portaudio
pip install pyaudio
❌ Error: “Unable to import ‘pvporcupine’”¶
# Install Picovoice
pip install pvporcupine
# Configure API key
export PICOVOICE_ACCESS_KEY="your_key"
❌ Error: “ALSA lib pcm_dsnoop.c” (Linux)¶
# Add to ~/.bashrc or ~/.zshrc:
export ALSA_PCM_CARD=0
export ALSA_PCM_DEVICE=0
# Or run with:
ALSA_PCM_CARD=0 ALSA_PCM_DEVICE=0 python test_timecraft_ai.py
❌ Error: “Access denied” (microphone)¶
- macOS: System Preferences > Security & Privacy > Privacy > Microphone
- Windows: Settings > Privacy > Microphone
- Linux: Check if user is in ‘audio’ group
❌ Error: “Model file not found”¶
# Check if model was downloaded correctly
ls -la models/vosk-model-small-pt/
# Re-download if necessary
cd models
rm -rf vosk-model-small-pt*
wget https://alphacephei.com/vosk/models/vosk-model-small-pt-0.3.zip
unzip vosk-model-small-pt-0.3.zip
mv vosk-model-small-pt-0.3 vosk-model-small-pt
🎯 Usage Modes¶
1. Basic Test¶
- Tests all basic functionalities
- Doesn’t require microphone/audio
2. FastAPI Server¶
- Starts web server on port 8000
- Access: http://localhost:8000/docs
3. Continuous Voice Mode¶
- Listens continuously
- Speak commands like: “history”, “prediction”, “insights”
4. Hotword Mode¶
- Waits for keyword “MCP”
- Then speak your command
🌐 API Endpoints¶
Health Check¶
Send Command¶
curl -X POST http://localhost:8000/mcp/command \
-H "Content-Type: application/json" \
-d '{"message": "show me the history"}'
List Plugins¶
Activate OpenAI Plugin¶
Configure API Key¶
curl -X POST http://localhost:8000/mcp/plugins/openai/config \
-H "Content-Type: application/json" \
-d '{"api_key": "your_openai_key"}'
🔬 Development¶
File Structure¶
src/timecraft_ai/
├── __init__.py
├── audio_processor.py # Audio capture and transcription
├── chatbot_actions.py # Chatbot actions (data, predictions)
├── chatbot_msgset.py # Message handler
├── chatbot_timecraft.py # Alternative Flask API
├── hotword_detector.py # Keyword detection
├── mcp_command_handler.py # Central command handler
├── mcp_server.py # Main FastAPI server
└── voice_synthesizer.py # Voice synthesis
Adding New Commands¶
- Edit
chatbot_actions.py
- add new methods - Edit
chatbot_msgset.py
- add recognition patterns - Test with
python test_timecraft_ai.py --mode voice
Integrating External LLMs¶
- Configure API key via endpoint
/mcp/plugins/{plugin}/config
- Activate plugin via
/mcp/plugins/{plugin}/enable
- Edit
mcp_command_handler.py
to route commands
📞 Support¶
Logs and Debug¶
# Run with detailed logs
export PYTHONPATH=$PWD/src
python -c "
import logging
logging.basicConfig(level=logging.DEBUG)
from timecraft_ai.audio_processor import AudioProcessor
# ... your test code
"
Contact¶
- 📧 Email: faelmori@gmail.com
- 🐙 GitHub: Issues
- 💬 LinkedIn: Rafa Mori
📄 License¶
MIT License - See LICENSE for details.