Giter Club home page Giter Club logo

autochord's Introduction

autochord

Automatic Chord Recognition tools

About

autochord is:

โœ” a Python library for automatic chord recognition (using TensorFlow)

โœ” a Javascript app for visualization of chord transcriptions:

Library Usage

To install library, run:

$ pip install autochord

autochord provides a very simple API for performing chord recognition:

import autochord
autochord.recognize('audio.wav', lab_fn='chords.lab')
# This gives out a list of tuples in the format:
#  (chord start, chord end, chord name)
# e.g.
# [(0.0, 5.944308390022676, 'D:maj'),
#  (5.944308390022676, 7.476825396825397, 'C:maj'),
#  (7.476825396825397, 18.250884353741498, 'D:maj'),
#  (18.250884353741498, 19.736961451247165, 'C:maj')
#  ...
#  (160.49632653061224, 162.30748299319728, 'N')]

Under the hood autochord.recognize() runs the NNLS-Chroma VAMP plugin to extract chroma features from the audio, and feeds it to a Bi-LSTM-CRF model in TensorFlow to recognize the chords. Currently, the model can recognize 25 chord classes: the 12 major triads, 12 minor triads, and no-chord ('N').

OPTIONALLY, you may dump the chords in a .lab file by using the lab_fn parameter. The output file follows the MIREX chord label format.

Upon import autochord takes care of setting up the VAMP plugin and downloading the pre-trained chord recognition model.

The measured test accuracy of the TensorFlow model is 67.33%. That may be enough for some songs, but we can explore in the future how to further improve this.

Supported Environments

  • Library has been tested to work out-of-the-box for Python 3 setup in Ubuntu (18.04).
  • Windows is unsupported (see issue)
  • OSX can be supported with some tweaks

App Usage

The app is pretty straightforward: you need to load a song, then you can upload a LAB file to visualize its chord labels. You may use the autochord Python library for generating this file. Optionally, you may load another LAB file for comparison (e.g. ground-truth labels, LAB file from another model's prediction).

Future Improvements

  • Integrate everything into a full chord recognition app! For that we need to:
    • convert VAMP plugin to JS module
    • model conversion to TensorFlow.js (as of writing, some CRF operations are not supported by TFJS yet)
    • converting all other Python functions to JS equivalent
  • Experimenting with other approaches to improve chord recognition accuracy

autochord's People

Contributors

cjbayron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

autochord's Issues

Complex chords

Hi there, thanks for the codes! It seems like it can only recognize simplified chords though, is it also capable of identifying more complicated chord qualities like aug6, min7b5 etc?

Thanks!

Aligning offsets with bars

My question here only applies to songs where both the tempo and the time signature are known, but that should be most of the songs out there.

Imagining a song in 4/4 with 120 qpm that changes chord every 4 bars, you would have a change every 8 seconds (quarter is 60s/120=0.5s, bar is 0.5s * 4 = 2s, chord length is 2s * 4 = 8s). So the ideal output would be for example:

0.0   8.0   E:min
8.0   16.0  A:maj
16.0  24.0  E:min
[.....]

In reality time offsets in the predictions are a bit wonky, that is probably because in real sound there is not really an exact time when a chord starts. I have also tested this on a .wav render of a midi.

If the tempo is low and bars are long then durations can be sort of quantised "with a wrench hit" by approximating to the closest bar, but when the tempo is high enough (100+?) the timing error becomes too big, making it impossible to pin exactly when in the score the chord is changed.

I don't know much about how your NN works, but perhaps this is because the wave is analysed "continuously"? could it be made to analyse segments that are aligned with bars instead? In the previous song, for example, could the prediction function be made to guess what chord is there from 0.0 to 2.0, then from 2.0 to 4.0, etc?

Thanks!

Just to say thank

image

It's amazing, I'm making an app to help myself learn guitar and the recognition is pretty accurate.

Keep the good work.

Error while installing autochord package

image

Anyone knows how could i resolve this error when i'm installing the package, aparently, the error occurs when it's going to install the vamp package as a dependency, in the setup.py files, it doesn't recognize the numpy package even if it's already installed.

I can't get nnls-chroma to work while importing autochord

When I import autochord, I get an error that says, "Vamp plugin has not been installed correctly" Says to put C:\Users[user].conda\envs\ldm\lib\site-packages\autochord\res\nnls-chroma.so to vamp plugin folder, which doesn't exist, so I put it in the Vamp library folder in my conda env packages but that didn't work either. Any help?

How to train autochord?

Hello there, and thanks again for the work!

I was wondering if it would be possible to run some training on the model in order to possibly increase the accuracy.

Would it be possible to know what data set you used and how?

Thanks!

How to run on OSX

Hi!

I know your project is only meant to be supported on Linux, but I got it running on Mac OSX (with m2 architecture!) and I'd like to share how I did it.

Feel free to make of this information what you wish.


  1. Install dependencies
    • brew install boost vamp-plugin-sdk
  2. Download nnls-chroma plugin
    • git clone https://github.com/c4dm/nnls-chroma; cd nnls-chroma
  3. Make the dependencies available in the source tree (edit version accordingly)
    • ln -s /opt/homebrew/Cellar/vamp-plugin-sdk/2.10.0/ vamp
    • ln -s /opt/homebrew/Cellar/boost/1.81.0_1 boost
  4. Horribly copy files around to be where the Makefile expects them
    • cp vamp/lib/*a vamp/include/
  5. Patch Makefile.osx as follows
diff --git a/Makefile.osx b/Makefile.osx
index d6fa701..46839a3 100644
--- a/Makefile.osx
+++ b/Makefile.osx
@@ -1,9 +1,9 @@

-VAMP_SDK_DIR = ../vamp-plugin-sdk
+VAMP_SDK_DIR = vamp/include

-BOOST_ROOT = ../boost_1_48_0
+BOOST_ROOT = boost/include

-ARCHFLAGS ?= -mmacosx-version-min=10.7 -arch x86_64
+ARCHFLAGS ?= -mmacosx-version-min=10.7
 OPTFLAGS  ?= -O3 -ffast-math
 PLUGIN_EXT = .dylib
  1. Build and install
    • make -f Makefile.osx
    • mkdir -p ~/Library/Audio/Plug-Ins/Vamp
    • cp nnls-chroma.dylib ~/Library/Audio/Plug-Ins/Vamp

Hope this may save a bit of time and headache to the next person trying to run this :)

Thanks for your work!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.