ML / AUDIO
Music Recommendation.
A Streamlit app that listens to an uploaded WAV file, predicts one of five genres, and recommends up to ten similar tracks using audio features.
- THE ROLE
- Machine Learning Developer · University Team Project
- THE WHEN
- 2024
- BUILT WITH
- PythonLibrosaSVMCosine SimilarityStreamlit
Starting with the sound
This university team project explores a simple question: can an uploaded song lead to other songs with similar audio characteristics? The app accepts a WAV file, plays it back, displays genre scores, and recommends tracks from its local library.
The system covers five genres: blues, classical, pop, reggae, and rock.
The recommendation pipeline
- Extract the audio features. Librosa computes 13 mel-frequency cepstral coefficients (MFCCs), summarized by their means across the track.
- Apply the training scaler. The saved StandardScaler transforms the uploaded track into the same feature space used to train the model.
- Classify the genre. A support vector machine selects the genre. The interface displays relative genre scores and a comparison chart.
- Rank similar tracks. Within the predicted genre, cosine similarity compares the upload against the library’s scaled feature vectors. The app returns up to ten matches and provides playback when the audio files are available.
Training and delivery
The training notebook uses an RBF-kernel SVM, an 80/20 train-test split, and five-fold grid search over its regularization and kernel parameters. Both the selected model and the fitted scaler are saved for the Streamlit app to reuse.
What I learned
The project brought feature extraction, classification, and retrieval into one working interface. It also made the consequences of the design clear: the predicted genre determines the recommendation pool, and similarity is based on the chosen audio features. Keeping training, library preparation, and inference consistent is essential to making that pipeline work.
CASE FILE / 06THAT'S THE STORY.
LET'S BUILD THE NEXT ONE ↗