An AI-powered system that generates personalized music and lighting recommendations based on emotional state descriptions.
Created by: Enzo Berreur & Elea Nizam & Camil Nitel
Synesthetic DJ is a machine learning project that bridges the gap between textual descriptions of emotions and multisensory ambient experiences. The system analyzes natural language input describing a user's mood and generates:
- Music recommendations from a curated catalog of 12 emotional soundscapes
- Dynamic lighting sequences with RGB color palettes, durations, and intensity levels
- Narrative descriptions that contextualize the generated ambiance
The name "Synesthetic DJ" draws inspiration from synesthesiaβa neurological phenomenon where stimulation of one sensory pathway leads to automatic experiences in another. Our system creates this cross-sensory mapping by training a language model to understand emotional descriptions and translate them into coordinated audio-visual recommendations.
The project leverages a fine-tuned Phi-3-mini-4k-instruct model with LoRA (Low-Rank Adaptation) adapters, trained on a custom dataset of ~520 examples mapping emotional descriptions to mood profiles.
Natural language description of emotional state:
"Je me sens joyeux ce matin et je veux une ambiance solaire"
Structured JSON response containing:
{
"track": {
"mood_id": "bonnehumeur",
"preview_uri": "gs://llmops-enzo/audio_previews/Bonnehumeur.mp3"
},
"lighting": [
{"rgb": [255, 210, 140], "duration": 12, "intensity": 0.55},
{"rgb": [250, 235, 180], "duration": 8, "intensity": 0.45}
],
"narration": "Ambiance solaire et dΓ©tendue pour entretenir cette bonne humeur.",
"diagnostics": {
"valence_hint": 0.9,
"arousal_hint": 0.4
}
}The project implements a complete MLOps workflow using Google Cloud Vertex AI Pipelines:
-
Data Transformation Component (
data_transformation_component.py)- Loads raw mood samples and catalog data from GCS
- Applies chat templates to format training examples
- Splits data into train/test sets (90/10 split)
- Outputs prepared datasets for downstream tasks
-
Fine-Tuning Component (
fine_tuning_component.py)- Fine-tunes microsoft/Phi-3-mini-4k-instruct using LoRA
- Configured for NVIDIA T4 GPU acceleration
- Produces an adapted model optimized for mood-to-ambiance generation
-
Inference Component (
inference_component.py)- Runs batch predictions on the test dataset
- Generates structured JSON outputs for evaluation
- Handles output parsing and error recovery
-
Evaluation Component (
evaluation_component.py)- Computes BLEU and ROUGE metrics
- Provides quantitative assessment of model quality
- Current performance: BLEU: 0.258 | ROUGE: 0.520
The system recognizes 12 distinct emotional states, each mapped to curated audio tracks and lighting profiles:
| Mood | Description |
|---|---|
| bonnehumeur | Ambiance solaire et dΓ©tendue |
| curiosite | Mouvement malicieux et lumineux |
| detente | Ondes bleues et calmes |
| euphorie | Flux explosif et lumineux |
| reverie | Atmosphère suspendue cosmique |
| victoire | Γclat victorieux |
| colere | Cadence intense |
| inquietude | Pulsations feutrΓ©es |
| nostalgie | Teintes sΓ©pia et rythme doux |
| panique | Impacts rapides |
| suspense | Texture feutrΓ©e |
| tristesse | Halo discret et consolant |
- Python 3.11.6 (exact version required)
- uv package manager
- Google Cloud SDK
- A GCP project with Vertex AI enabled
Install dependencies and create virtual environment:
uv venv
uv syncActivate the virtual environment:
source .venv/bin/activateAuthenticate with Google Cloud:
gcloud auth login
gcloud auth application-default login
gcloud config set project YOUR_PROJECT_IDEnable required GCP APIs:
gcloud services enable aiplatform.googleapis.com
gcloud services enable storage-component.googleapis.com
gcloud services enable cloudresourcemanager.googleapis.com-
Copy the example environment file:
cp .env.example .env
-
Edit
.envand fill in your values:GCP_PROJECT_ID: Your GCP project IDGCP_PROJECT_NUMBER: Your GCP project numberGCP_BUCKET_NAME: Your GCS bucket nameGCP_REGION: Deployment region (e.g.,europe-west2)- Upload mood datasets (
mood_samples.csvandmood_catalog.csv) to your GCS bucket
-
Load environment variables:
export $(cat .env | xargs)
If you need to train a new model from scratch:
source .venv/bin/activate
export $(cat .env | xargs)
PYTHONPATH=. python scripts/pipeline_runner.pyThis orchestrates: data transformation β fine-tuning β inference β evaluation (takes ~2-3 hours with GPU).
A. List available models in Vertex AI:
source .venv/bin/activate
export $(cat .env | xargs)
python -c "
from google.cloud import aiplatform
from src.constants import PROJECT_ID, REGION
aiplatform.init(project=PROJECT_ID, location=REGION)
models = aiplatform.Model.list()
for i, model in enumerate(models, 1):
print(f'{i}. {model.display_name}')
print(f' Resource: {model.resource_name}')
print()
"B. Deploy your model to an endpoint:
Replace MODEL_RESOURCE_NAME with the resource name from step A (e.g., projects/54825872111/locations/europe-west2/models/9017459897251397632):
source .venv/bin/activate
export $(cat .env | xargs)
python scripts/deploy_model.py "MODEL_RESOURCE_NAME"β±οΈ Deployment takes ~10-15 minutes
C. After deployment completes:
The script will output an Endpoint ID. Copy it and update your .env file:
GCP_ENDPOINT_ID=your_new_endpoint_id_hereD. Verify deployment status:
source .venv/bin/activate
export $(cat .env | xargs)
python scripts/check_endpoint_status.py YOUR_ENDPOINT_IDOnce deployed, test the endpoint with a sample mood description:
source .venv/bin/activate
export $(cat .env | xargs)
python scripts/test_endpoint.py YOUR_ENDPOINT_ID \
--test-input "Je me sens euphorique après avoir gagné la compétition"The project includes a Chainlit-based web interface (src/app/synesthetic_dj.py) that provides an immersive user experience:
- Chat interface for natural language mood descriptions
- Audio playback with automatic track streaming from GCS
- Dynamic lighting animations rendered as CSS animations with radial gradients and glow effects
- Real-time narration explaining the generated ambiance
Prerequisites: Make sure your model is deployed and GCP_ENDPOINT_ID is set in .env
source .venv/bin/activate
export $(cat .env | xargs)
PYTHONPATH=. chainlit run src/app/synesthetic_dj.py --port 8000Then open your browser at: http://localhost:8000
The app features:
- π Starter prompts for common moods (Bonne humeur, Tristesse, Euphorie, DΓ©tente)
- π¨ Immersive lighting overlays synchronized with audio
- π΅ Audio preview playback from GCS
- β¨ Graceful error handling and loading states
- π Support for both GCS and HTTP audio sources
After initial setup, use these commands to launch the app:
cd "/path/to/llmops_final"
source .venv/bin/activate
export $(cat .env | xargs)
PYTHONPATH=. chainlit run src/app/synesthetic_dj.py --port 8000- ML Framework: Hugging Face Transformers, PEFT (LoRA), TRL
- Base Model: microsoft/Phi-3-mini-4k-instruct
- Cloud Infrastructure: Google Cloud Vertex AI (Pipelines, Model Registry, Endpoints)
- Pipeline Orchestration: Kubeflow Pipelines (KFP)
- Storage: Google Cloud Storage
- Web Framework: Chainlit
- Data Processing: Pandas, Datasets
- Evaluation: ROUGE Score, SacreBLEU
.
βββ src/
β βββ app/
β β βββ main.py # Legacy Chainlit app (Yoda LLM)
β β βββ synesthetic_dj.py # Synesthetic DJ Chainlit app
β βββ pipeline_components/
β β βββ data_transformation_component.py
β β βββ fine_tuning_component.py
β β βββ inference_component.py
β β βββ evaluation_component.py
β βββ pipelines/
β β βββ model_training_pipeline.py # KFP pipeline definition
β βββ constants.py # Project-wide constants
β βββ handler.py # Custom prediction handler
βββ scripts/
β βββ pipeline_runner.py # Execute training pipeline
β βββ deploy_model.py # Deploy model to endpoint
β βββ test_endpoint.py # Test deployed endpoint
β βββ check_endpoint_status.py # Monitor deployment status
β βββ register_model_with_custom_handler.py
β βββ make_audio_public.py # Manage GCS audio permissions
β βββ validate_gcp_setup.py # Verify GCP configuration
βββ data/
β βββ mood_catalog.csv # Mood definitions
β βββ mood_samples.csv # Training examples
βββ audio/ # Local audio preview files
βββ chainlit.md # Chainlit app documentation
βββ GUIDE.md # Deployment guide
βββ pyproject.toml # Python dependencies
- Expanded mood catalog with more granular emotional states
- Real-time audio generation using generative audio models
- Hardware integration for physical smart lighting control (Philips Hue, etc.)
- Multilingual support for mood descriptions
- User feedback loop to continuously improve recommendations
- Temporal awareness to adapt ambiances based on time of day
This project was developed as part of the LLMOps curriculum at Albert School.