-
Notifications
You must be signed in to change notification settings - Fork 12
Installation
- Operating System: Windows, macOS, or Linux
- Python: Version 2.7 or 3.6+ (code uses Python 2 pickle format)
- Webcam: Required for emotion detection
- Internet: Required for Algorithmia API calls
- Browser: Modern browser with WebRTC support (Chrome, Firefox, Safari, Edge)
- Algorithmia Account: Free tier available at algorithmia.com
# If using git
git clone <repository-url>
cd muze
# Or download and extract ZIP filepip install Flask==0.12.2
pip install hsaudiotag==1.1.1
pip install Jinja2==2.10
pip install matplotlib==2.1.2
pip install numpy==1.14.0
pip install Pillow==5.0.0
pip install simplejson==3.13.2
pip install six==1.11.0
pip install urllib3==1.22
pip install Werkzeug==0.14.1
pip install Algorithmiapip install -r requirements.txtIf not present, create requirements.txt:
Flask==0.12.2
hsaudiotag==1.1.1
Jinja2==2.10
matplotlib==2.1.2
numpy==1.14.0
Pillow==5.0.0
simplejson==3.13.2
six==1.11.0
urllib3==1.22
Werkzeug==0.14.1
Algorithmia>=1.0.0- Visit algorithmia.com
- Sign up for a free account
- Navigate to your profile
- Click on "Credentials" section
- Copy your API key (starts with "sim...")
Open algorithmia.py and replace the API key on line 17:
# Before
client = Algorithmia.client('api-key')
# After
client = Algorithmia.client('simYOUR_ACTUAL_API_KEY_HERE')Better approach (recommended):
Create a .env file:
ALGORITHMIA_API_KEY=simYOUR_ACTUAL_API_KEY_HEREUpdate algorithmia.py:
import os
from dotenv import load_dotenv
load_dotenv()
client = Algorithmia.client(os.getenv('ALGORITHMIA_API_KEY'))Install python-dotenv:
pip install python-dotenvEnsure these directories exist:
muze/
├── app.py
├── algorithmia.py
├── test.txt
├── snapshots/ # Create if missing
├── static/
│ ├── music/ # Should contain 001.mp3 - 903.mp3
│ └── jquery-1.7.1.min.js
└── templates/
├── base.html
└── musi.htmlCreate missing directories:
mkdir -p snapshots
mkdir -p static/musicCheck that music files are present:
# Windows
dir static\music\*.mp3
# macOS/Linux
ls static/music/*.mp3You should see files: 001.mp3, 002.mp3, ..., 903.mp3
If music files are missing: You'll need to obtain them from the MIREX 2007 dataset or provide your own music library.
python app.pyExpected output:
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger PIN: XXX-XXX-XXX
- Open your web browser
- Navigate to:
http://localhost:5000 - Allow webcam access when prompted
- Wait 5 seconds for initial snapshot
- Enjoy your personalized playlist!
Problem: SyntaxError or compatibility issues
Solution: Check Python version
python --versionIf using Python 3, ensure all code is compatible or use Python 2.7.
Problem: UnicodeDecodeError when loading test.txt
Solution: Ensure encoding parameter is used
pickle.load(fp, encoding='latin1')Problem: ModuleNotFoundError: No module named 'flask'
Solution: Install missing module
pip install flaskProblem: ImportError: No module named Algorithmia
Solution: Install Algorithmia SDK
pip install AlgorithmiaProblem: OSError: [Errno 48] Address already in use
Solution: Change port in app.py
if __name__ == '__main__':
app.run(debug=True, port=5001) # Use different portOr kill existing process:
# Find process using port 5000
lsof -i :5000
# Kill process
kill -9 <PID>Problem: "getUserMedia not supported" or permission denied
Solutions:
- Use HTTPS (required for some browsers)
- Check browser permissions
- Ensure webcam is not in use by another app
- Try different browser
Problem: AlgorithmException: authorization required
Solution:
- Verify API key is correct
- Check Algorithmia account is active
- Ensure API key has proper permissions
Problem: Audio player shows error or no sound
Solution:
- Verify MP3 files exist in
static/music/ - Check file naming (001.mp3, not 1.mp3)
- Ensure files are valid MP3 format
python -c "import flask, Algorithmia, PIL, numpy, matplotlib; print('All modules imported successfully')"# Check read permissions
python -c "import pickle; pickle.load(open('test.txt', 'rb'), encoding='latin1'); print('Song database loaded')"
# Check write permissions
python -c "open('snapshots/test.txt', 'w').write('test'); print('Snapshot directory writable')"import Algorithmia
client = Algorithmia.client('YOUR_API_KEY')
algo = client.algo('deeplearning/EmotionRecognitionCNNMBP/1.0.1')
print("API connection successful")python app.py &
curl http://localhost:5000
# Should return HTML contentFROM python:3.8-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
EXPOSE 5000
ENV FLASK_APP=app.py
ENV FLASK_ENV=development
CMD ["python", "app.py"]# Build image
docker build -t muze .
# Run container
docker run -p 5000:5000 -e ALGORITHMIA_API_KEY=your_key muze# Python 3
python -m venv venv
# Python 2
virtualenv venv# Windows
venv\Scripts\activate
# macOS/Linux
source venv/bin/activatepip install -r requirements.txtdeactivate# Install Gunicorn
pip install gunicorn
# Run with 4 workers
gunicorn -w 4 -b 0.0.0.0:5000 app:app# Install Waitress
pip install waitress
# Run server
waitress-serve --port=5000 app:appCreate .env file for production:
FLASK_ENV=production
FLASK_DEBUG=False
SECRET_KEY=your_secure_random_secret_key
ALGORITHMIA_API_KEY=your_api_key- Change Flask secret key from "bacon"
- Move API key to environment variable
- Use HTTPS in production
- Configure CORS properly
- Add rate limiting
- Implement input validation
- Set up logging
- Configure firewall rules
After successful installation:
- Read the Quick Start Guide
- Review Configuration options
- Explore API Reference
- Check Troubleshooting for common issues
# Deactivate if active
deactivate
# Remove directory
rm -rf venv# Delete application directory
rm -rf muzepip uninstall Flask hsaudiotag Jinja2 matplotlib numpy Pillow simplejson six urllib3 Werkzeug Algorithmia