Skip to main content

Python audio signal processing library for musical tempo detection

Project description

https://img.shields.io/badge/License-AGPL%20v3-blue.svg https://zenodo.org/badge/DOI/10.5281/zenodo.1492353.svg https://zenodo.org/badge/DOI/10.5281/zenodo.3553592.svg

Tempo-CNN

Tempo-CNN is a simple CNN-based framework for estimating temporal properties of music tracks.

First and foremost, Tempo-CNN is a tempo estimator. To determine the global tempo of an audio file, simply run the script

tempo -i my_audio.wav

You may specify other models and output formats (mirex, JAMS) via command line parameters.

E.g. to create JAMS as output format and the model originally used in the ISMIR 2018 paper [1], please run

tempo -m ismir2018 --jams -i my_audio.wav

DeepTemp Models

To use one of the DeepTemp models from [3] (see also repo directional_cnns), run

tempo -m deeptemp --jams -i my_audio.wav

or,

tempo -m deeptemp_k24 --jams -i my_audio.wav

if you want to use a higher capacity model (some k-values are supported). deepsquare and shallowtemp models may also be used.

Mazurka Models

To use DT-Maz models from [4], run

tempo -m mazurka -i my_audio.wav

This defaults to the model named dt_maz_v_fold0. You may choose another fold [0-4] or another split [v|m]. So to use fold 3 from the M-split, use

tempo -m dt_maz_m_fold3 -i my_audio.wav

Batch Processing

For batch processing, you may want to run tempo like this:

find /your_audio_dir/ -name '*.wav' -print0 | xargs -0 tempo -d /output_dir/ -i

This will recursively search for all .wav files in /your_audio_dir/, analyze then and write the results to individual files in /output_dir/. Because the model is only loaded once, this method of processing is much faster than individual program starts.

Interpolation

To increase accuracy for greater than integer-precision, you may want to enable quadratic interpolation. You can do so by setting the --interpolate flag. Obviously, this only makes sense for tracks with a very stable tempo:

tempo -m ismir2018 --interpolate -i my_audio.wav

Tempogram

Instead of estimating a global tempo, Tempo-CNN can also estimate local tempi in the form of a tempogram. This can be useful for identifying tempo drift.

To create such a tempogram, run

tempogram -p my_audio.wav

As output, tempogram will create a .png file. Additional options to select different models and output formats are available.

You may use the --csv option to export local tempo estimates in a parseable format and the --hop-length option to change temporal resolution. The parameters --sharpen and --norm-frame let you post-process the image.

Tempo-CNN provides experimental support for temporal property estimation of Greek folk music [2]. The corresponding models are named fma2018 (for tempo) and fma2018-meter (for meter). To estimate the meter’s numerator, run

meter -m fma2018-meter -i my_audio.wav

Installation

Clone this repo and run setup.py install using Python 3.6:

git clone https://github.com/hendriks73/tempo-cnn.git
cd tempo-cnn
python setup.py install

You may need to install TensorFlow using pip from the command line.

License

Source code and models can be licensed under the GNU AFFERO GENERAL PUBLIC LICENSE v3. For details, please see the LICENSE file.

Citation

If you use Tempo-CNN in your work, please consider citing it.

Original publication:

@inproceedings{SchreiberM18_TempoCNN_ISMIR,
   Title = {A Single-Step Approach to Musical Tempo Estimation Using a Convolutional Neural Network},
   Author = {Schreiber, Hendrik and M{\"u}ller Meinard},
   Booktitle = {Proceedings of the 19th International Society for Music Information Retrieval Conference ({ISMIR})},
   Pages = {98--105},
   Month = {9},
   Year = {2018},
   Address = {Paris, France},
   doi = {10.5281/zenodo.1492353},
   url = {https://doi.org/10.5281/zenodo.1492353}
}

ShallowTemp, DeepTemp, and DeepSquare models:

@inproceedings{SchreiberM19_CNNKeyTempo_SMC,
   Title = {Musical Tempo and Key Estimation using Convolutional Neural Networks with Directional Filters},
   Author = {Hendrik Schreiber and Meinard M{\"u}ller},
   Booktitle = {Proceedings of the Sound and Music Computing Conference ({SMC})},
   Pages = {47--54},
   Year = {2019},
   Address = {M{\'a}laga, Spain}
}

Mazurka models:

@inproceedings{SchreiberZM20_LocalTempo_ISMIR,
   Title = {Modeling and Estimating Local Tempo: A Case Study on Chopin’s Mazurkas},
   Author = {Hendrik Schreiber and Frank Zalkow and Meinard M{\"u}ller},
   Booktitle = {Proceedings of the 21th International Society for Music Information Retrieval Conference ({ISMIR})},
   Year = {2020},
   Address = {Montreal, QC, Canada}
}

References

Changes

0.0.5:
  • Moved to TensorFlow 1.15.4.

  • Consolidated version info.

  • Consolidated requirements.

  • Switched to pytest.

  • Officially support Python 3.7.

  • Enabled GitHub actions for packaging and testing.

  • Added Pypi workflow.

  • Cache models locally.

  • Load models from GitHub.

0.0.4:
  • Added support for DeepTemp, DeepSquare, and ShallowTemp models.

  • Added support for Mazurka models.

  • Added support for exporting data from tempograms.

  • Added support for framewise normalization in tempograms.

  • Moved to TensorFlow 1.15.2.

  • Print number of model parameters.

0.0.3:
  • Added flag --interpolate for tempo to increase accuracy.

  • Migrated models to TensorFlow 1.10.1.

0.0.2:
  • Added -d option for improved batch processing (tempo)

  • Improved jams output

  • Moved to librosa 0.6.2

  • Continue processing batch, even when encountering an error

0.0.1:
  • Initial version

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tempocnn-0.0.5.dev0.tar.gz (70.0 MB view details)

Uploaded Source

Built Distribution

tempocnn-0.0.5.dev0-py3-none-any.whl (70.0 MB view details)

Uploaded Python 3

File details

Details for the file tempocnn-0.0.5.dev0.tar.gz.

File metadata

  • Download URL: tempocnn-0.0.5.dev0.tar.gz
  • Upload date:
  • Size: 70.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.9

File hashes

Hashes for tempocnn-0.0.5.dev0.tar.gz
Algorithm Hash digest
SHA256 0812e51ce5c5f620df77dd2f9cdcf0820d2f2db2d9996adfe0c46954fc6b6779
MD5 3103fa0b846dc180027d340d66c413ad
BLAKE2b-256 d908d24fb14f6563988ee5f5db6869183a10823513ce700ec7f30148399c1ffe

See more details on using hashes here.

File details

Details for the file tempocnn-0.0.5.dev0-py3-none-any.whl.

File metadata

  • Download URL: tempocnn-0.0.5.dev0-py3-none-any.whl
  • Upload date:
  • Size: 70.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.9

File hashes

Hashes for tempocnn-0.0.5.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 e3bc5fab75e14bfe633a963bffc8bd57943b67ad9559c45523b3833ab2a3d471
MD5 0cfe409a65a729ab2dc3eb3e262adca6
BLAKE2b-256 1a804a217907fed913befbe92a9f84aef6e827dba27b6bdcea4a5997fe08b826

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page