Code Monkey home page Code Monkey logo

keras-music-generation's Introduction

Keras Music Composer

This model uses deep learning with Keras and a LSTM to compose music. Music, here is stored as MIDI files, which can be trained on. The model will then compose original music based on the music it has received as training examples. In this example, it will train on music from the composer Frédéric Chopin.

Video Demo

Preprocessing

The model takes MIDI files, which often have more than one track. These are processed by choosing a track on which to train on, and using the music21 library to create a dictionary of notes and chords which were used in the song. Before being fed into the model, they are converted with one-hot-encoding based on the note or chord at each time in the song.

Train

Results

One way to tune this model is to adjust the length of the sequence fed into the LSTM. For example, when using 20 notes as a sequence, the model's output tends to get stuck after a little while and doesn't know what to predict next so it predicts the same thing a few times before figuring out what to do. When using a 50 note sequence this does not occur. In this situation, the model does not generalize as well since it is only trained on one song each time. When trained with a sequence of twenty, one output can be seen here:

Twenty

When training with a sequence of fifty, one output can be seen here. As can be noticed, training with fifty does not lead to a short sequence where the same note is repeated.

Fifty

Data

The data which was used to train on can be seen in the "trainedOn" folder, although any MIDI file with a melody should work (just make sure the track number on preprocessing is changed). Example MIDI outputs can be found in the output folder. To listen to how they sound, you can drag them onto any music creation software like Garageband, Logic, etc.

Running the model

The only thing necessary to change before running the model is creating a folder entitled 'music' and including the MIDI file on which to train on in it.

keras-music-generation's People

Contributors

mkutr avatar will108 avatar

Watchers

 avatar

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.