Rhythm Pattern music feature extractor by IFS @ TU-Vienna
Jupyter Notebook Python
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin/external/win init Mar 25, 2015
models updating default genre model Dec 10, 2015
music added again example mp3 Jul 20, 2015
.gitignore removed .py from .gitignore file Jun 18, 2018
.project init Mar 25, 2015
LICENSE Initial commit Mar 25, 2015
Logger.py added Logger class Jun 18, 2015
README.md minor corrections Oct 12, 2016
RP_extract_Tutorial.ipynb reduced to functions now being part of rp_extract Dec 4, 2015
RP_extract_Tutorial.v3.ipynb renamed tutorial files Jul 13, 2015
RP_extract_Tutorial.v4.ipynb added Tutorial in Jupyter Notebook version v4 Aug 13, 2018
RP_extract_Tutorial1.ipynb renamed tutorial files Jul 13, 2015
__init__.py added __init__.py to allow to be imported as module Jun 18, 2018
audiofile_read.py added support for .mp4 in the "audio" formats Aug 3, 2018
classes_io.py global import pandas as pd Jan 4, 2017
requirements.txt removed double requirement Aug 9, 2018
requirements_optional.txt added optional requirement Nov 17, 2017
rp_classify.py switched to scikit-learn>=0.18 Aug 3, 2018
rp_extract.py solved another bug where bark band #24 was never computed (was always… Oct 23, 2017
rp_extract_batch.py making executable Feb 7, 2017
rp_feature_io.py aligning verbose output when reading features Sep 25, 2017
rp_plot.py changing to colormap jet again (was changed by matplotlib in the mean… Oct 23, 2017
setup.cfg adding setup files in preparation for PiPy submit Jan 5, 2016
setup.py adding setup files in preparation for PiPy submit Jan 5, 2016
wavio.py added TODO to possibly integrate newer wavio Sep 8, 2016

README.md

RP_extract:

Rhythm Pattern Audio Feature Extractor

for Music Similarity, Music Classification and Music Recommendation

created by:

TU Wien
Music Information Retrieval Group
Institute of Software Technology and Interactive Systems
Vienna University of Technology, Austria

RP_extract is a Python library to extract semantic features (so called audio descriptors) from audio files (WAV, MP3, ...) which can be used in tasks such as finding similar sounding music, creating playlists or recommender systems, categorizing music into a custom set of categories such as genres, and detecting concepts such as moods and emotions in music. Most of these tasks are achieved through employing Machine Learning, example implementations are provided in this repository and the tutorials included.

Main Authors: Thomas Lidy (audiofeature), Alexander Schindler (slychief)

Installation

[Python 2.7] (https://www.python.org/downloads/release/python-2712/) is required.

Operating Systems

Linux, Mac and Windows are supported. We recommend Ubuntu 14.04 or 16.04.

Download

Either download as ZIP from https://github.com/tuwien-musicir/rp_extract/archive/master.zip , or:

git clone https://github.com/tuwien-musicir/rp_extract.git

Install Dependencies

On Linux Ubuntu many dependencies can be installed from the Software Center or repository like this:

sudo apt-get install python-numpy python-scipy python-pandas python-scikits-learn

Use this to install the remaining dependencies on Ubuntu, respectively all dependencies on Mac and Windows:

sudo pip install -r requirements.txt

Note that some of the requirements are only needed for specific parts of the library. If all you want to use is the audio analysis part with rp_extract.py, numpy and scipy are the only requirements.

Optional Dependencies

MP3 Decoder

If you want to use MP3, M4A, FLAC or AIF(F) files as input, you need to have one of the following decoders installed in your system: (Note: lame and mpg123 only support MP3, ffmpeg supports MP3 and all other formats)

Other

For plotting (using rp_plot.py)

sudo apt-get install python-matplotlib

For HDF5 file output instead of CSV:

Ubuntu Linux:

sudo apt-get install libhdf5-serial-dev python-tables

Mac OS X: (homebrew must be installed first)

brew tap homebrew/science
brew install hdf5
sudo pip install tables

Easy Getting Started

Analyze all audio files in a folder and store the extracted features:

python rp_extract_batch.py <input_path> <feature_file_name>

This will

  • search for WAV, MP3, M4A, FLAC or AIFF files in input_path
  • extract a standard set of audio features (RP, SSD, RH - see http://ifs.tuwien.ac.at/mir/audiofeatureextraction.html )
  • write them in CSV format to feature_file_name (don't specify a file extension, it will create 3 files, one for each feature type: .rp, .ssd, .rh)

Optionally specify the type of features you want:

python rp_extract_batch.py -rp -mvd -tssd <input_path> <feature_file_name>

Use the following to get a list of possible feature options:

python rp_extract_batch.py -h

Use RP_extract in your code

rp_extract.py is the main feature extractor. It can be imported and used in your code to do segment-level audio feature analysis.

For a step-by-step tutorial open „RP_extract Tutorial.ipynb“ in iPython Notebook or view the tutorial here:

http://nbviewer.ipython.org/github/tuwien-musicir/rp_extract/blob/master/RP_extract_Tutorial.ipynb

It also includes examples on how to compute music similarity, e.g. for music recommendation or creating playlists of coherent music.

Genre Recognition and Classification

rp_classify.py will analyze audio files and categorize them into a high-level concept (such as genre, style or mood) given a pre-trained classifier model that was created based on training data.

It can be used on a single audio file (wav or mp3) to recognize its genre like this:

python rp_classify.py music/BoxCat_Games_-_10_-_Epic_Song.mp3

will output:

music/BoxCat_Games_-_10_-_Epic_Song.mp3:	pop

You can also use a folder as an input, to analyze and predict all audio files contained. The full syntax is:

python rp_classify.py input_path model_file output_filename

input_path can be: a folder, wav, mp3, m4a or aif(f) file, or txt file containing a line-wise list of audio files

The pre-trained model included in this code repository (models/GTZAN) can predict these 10 genres:

blues, classical, country, disco, hiphop, jazz, metal, pop, reggae, rock

output_filename is an optional file in which predictions will be written in a TAB-separated way (if omitted, result will be printed to stdout).

Train a model:

You can train your own model like this:

python rp_classify.py -t input_path model_file

In this case files from input_path will be read and analyzed and a model will be trained and stored in model_file.

In this default case, files in input_path must be organized in sub-folders named like the categories to be used for training (e.g. one folder named 'pop', one for 'electronic', one for 'classical' etc.)

Alternatively, you can provide the class labels for training a new model in two alternative ways, adding an additional parameter to the command line:

  • -c classfile: expects the name of a TAB-separated file, where each line contains <audiofilename> TAB <class_label>
  • -m multiclassfile: also a TAB-separated file with <audiofilename> in the first column, and additional columns with the class labels in the header (1st line) and an 'x' for each file belonging to the class, an empty TAB position otherwise.

Once you trained a model in one of these ways, you can do predictions like above:

python rp_classify.py input_path model_file output_filename

Note: Specify the model_file always without file extension as 3 files will be generated with different extensions.

More Information

http://ifs.tuwien.ac.at/mir

http://ifs.tuwien.ac.at/mir/audiofeatureextraction.html

http://ifs.tuwien.ac.at/mir/downloads.html