This project classifies music genres using a Recurrent Neural Network (RNN) trained on audio features extracted from music files. It leverages the librosa library for audio processing, tensorflow for the model, and pydub for audio format conversion. The accuracy is 55%(for now).
Make sure you have Python installed on your machine. You can set up the required packages using pip. Create a virtual environment and install the dependencies as follows:
pip install pandas librosa tensorflow pydub numpy- Place your
.mp3audio file assample.mp3in theMusic_Genre_Classifierdirectory. - Run the script to predict the genre of the audio file:
python python Music_Genre_Classifier/musicgenre.pypandas: For data manipulation and analysis.librosa: For audio and music analysis.tensorflow: For building and loading the neural network model.pydub: For audio file format conversion.numpy: For numerical operations.
-
Feature Extraction: The audio file is loaded, and Mel-frequency cepstral coefficients (MFCC) are extracted to represent the audio features.
-
Model Loading: The pre-trained RNN model on GTZAN dataset is loaded from the specified file path.
-
Audio Conversion: If your input file is in
.mp3format, it is converted to.wavusingpydub. -
Prediction: The extracted features are fed into the model to predict the genre. The output is the genre label corresponding to the predicted index.
-
Output: The predicted genre is printed to the console.