madmom.features.key

This module contains key recognition related functionality.

madmom.features.key.key_prediction_to_label(prediction)[source]

Convert key class id to a human-readable key name.

Parameters:
prediction : numpy array

Array containing the probabilities of each key class.

Returns:
str

Human-readable key name.

class madmom.features.key.CNNKeyRecognitionProcessor(nn_files=None, **kwargs)[source]

Recognise the global key of a musical piece using a Convolutional Neural Network as described in [1].

Parameters:
nn_files : list, optional

List with trained CNN model files. Per default (‘None’), an ensemble of networks will be used.

References

[1](1, 2) Filip Korzeniowski and Gerhard Widmer, “Genre-Agnostic Key Classification with Convolutional Neural Networks”, In Proceedings of the 19th International Society for Music Information Retrieval Conference (ISMIR), Paris, France, 2018.

Examples

Create a CNNKeyRecognitionProcessor and pass a file through it. The returned array represents the probability of each key class.

>>> proc = CNNKeyRecognitionProcessor()
>>> proc  
<madmom.features.key.CNNKeyRecognitionProcessor object at 0x...>
>>> proc('tests/data/audio/sample.wav')  
array([[0.03426, 0.0331 , 0.02979, 0.04423, 0.04215, 0.0311 , 0.05225,
        0.04263, 0.04141, 0.02907, 0.03755, 0.09546, 0.0431 , 0.02792,
        0.02138, 0.05589, 0.03276, 0.02786, 0.02415, 0.04608, 0.05329,
        0.02804, 0.03868, 0.08786]])