Introduction

There are many different types of genres present in the industry. But the basic genres will have a few principle aspects that make it easier to identify them. Genres are used to tag and define different kinds of music based on the way they are composed or based on their musical form and musical style.

In this article, you will learn to build your own model which will take in a song as an input and predict or classify that particular song in one of the genres. We will be classifying among the following basic genres — blues. classical, country, disco, hip hop, jazz, metal, pop, reggae and rock. The model will be build using LSTM networks. Don’t worry if you do not know what LSTM is. This article will give you a brief understanding of LSTM and its working.

Here is the GitHub link to the entire project — https://github.com/rajatkeshri/Music-Genre-Prediction-Using-RNN-LSTM

The entire article is divided into 4segments —

  1. Prerequisites
  2. Theory
  3. Data Preprocessing
  4. Training the model
  5. Predicting on new data

Prerequisites

There are a few prerequisites you will need to have before you start this project. The first thing you would require is the dataset. The music data which I have used for this project can be downloaded from kaggle — https://www.kaggle.com/andradaolteanu/gtzan-dataset-music-genre-classification.

Note that this dataset contains 10 classes with 100 songs withing each class. This might sound to be very less for a machine learning project, that is why in the next section I will show you how to increase the number of training data for each class of genre.

There are a few modules which will be required for you to install in your PC/laptop in order to get started. We will be building the entire LSTM model using Tensorflow, coded in python. We will be working with python 3.6 or higher (If you are using python 2.7, it is required for you to use python 3.6 or higher for full support and functionality). The following are the required python packages to be installed —

  1. Tensorflow — Machine learning library
  2. librosa — Speech processing library to extract features from songs
  3. numpy — Mathematical model for scientific computing
  4. sklrean — Another machine learning model (We will use this library to split training and testing data)
  5. json — To jsonify the dataset (Explained in the next section)
  6. pytdub — To convert mp3 to wav files

These modules can be installed using pip or conda. You can find many online sources and youtube videos on getting started with pip or conda. Once the above modules are installed, let’s get coding!

#spotify #mfcc #music-genre #classification #lstm #algorithms

Breaking Spotify’s Algorithm of Music Genre Classification!
4.70 GEEK