I Don’t Use Spotify. So I Built My Own AI DJ.
Summary
A product manager developed a "Personal AI DJ" to replicate Spotify's AI-powered playlist feature for YouTube Music, which lacks a public API. The system allows users to generate playlists from their personal library based on natural language prompts like "melancholy songs I have not listened to for a while." The architecture involves extracting a user's YouTube Music library and Google Takeout watch history, enriching song metadata using GPT-4o-mini, web search, and Last.fm tags, converting descriptions into OpenAI embeddings, and storing them in a Supabase pgvector database containing 2,759 songs. Key challenges included the absence of a YouTube Music API, the need to parse Google Takeout for play history, and enriching descriptions for obscure songs not well-represented in LLM training data, which was addressed by a confidence scoring system and cost-effective web search via Brave Search API.
Key takeaway
For AI Engineers or Machine Learning Engineers looking to build personalized content systems without official APIs, you should prioritize robust data acquisition and enrichment strategies. Expect to combine multiple data sources like reverse-engineered libraries, user data exports, and external tagging services (e.g., Last.fm) to create comprehensive metadata. Be prepared to manage LLM costs for enrichment, potentially by separating web search from LLM synthesis, and consider open-source audio analysis tools like Essentia or librosa for deeper feature extraction.
Key insights
Building a personalized AI music curator requires overcoming API limitations and enriching diverse, often obscure, music metadata.
Principles
- Reverse-engineer APIs when official access is unavailable.
- Combine semantic and historical data for nuanced retrieval.
- Iteratively enrich data to improve LLM performance on niche content.
Method
The method involves extracting music library data via reverse-engineered APIs and Google Takeout, enriching song descriptions with LLMs, web search, and Last.fm tags, generating vector embeddings, and using a RAG pipeline with a vector database for query-based playlist generation.
In practice
- Use `ytmusicapi` for YouTube Music library access.
- Parse `watch_history.json` from Google Takeout for play data.
- Employ Brave Search API for cost-effective web enrichment.
Topics
- Personal AI DJ
- YouTube Music Integration
- RAG Pipeline
- Vector Embeddings
- LLM Enrichment
Code references
Best for: Machine Learning Engineer, AI Engineer, Software Engineer
Related on AIssential
Editorial summary, takeaway, and curation by AIssential. Original article published by AI Advances - Medium.