Git Product home page Git Product logo

musicgeneration-pianomusic's Introduction

MusicGeneration-PianoMusic

Spring 2018 - Repository for Team Ex Machina

KrakenKeys is a research project exploring the role of artificial intelligence in developing new musical compositions given a theme or genre. Primarily this involves using algorithms such as recurrent neural network, and lstm for generating musical notes. It also involved using open source tools such as TensorFlow Seq2Seq for training the ai on the note and chord patterns. The project also used Music21 for extracting piano notes and chords from midi and musicXML files. This allows building a creative tool for artists with artists block.

Getting Started

Installation

Dependencies

Name Versions
TensorFlow 1.5
Keras 2.1.5
Music21 5.2.0

These instructions will assume you are using Anaconda and TensorFlow.

If you do not have Anaconda and TensorFlow install it first.

Install Music21

If you are running Mac OS X or Ubuntu, you can just paste the following command into your terminal.

pip3 install music21

Using KrakenKeys

Run Our Pre-Trained Model

We have included an already trained model in the github repo which was trained on the midi files in the pirate_midis directory.

To generate a song using our pre-trained model run

python generate.py pirate_model

which will generate the file test.midi

Train your own model

The generation of a song from scratch is broken up into three separate python files. create_dataset.py, train_model.py, and generate.py. We have a included a small data set in the directory test_midi which is in the github repo.

create_dataset.py

Parses midi and xml files from a given directory path_to_dataset into notes by using music21 converter. It returns a list of all piano notes.

To generate the questions.txt and answers.txt files needed for training, run

python create_dataset.py <path_to_dataset>

python create_dataset.py ./pirate_midis

python create_dataset.py ./test_midi

Include a '**' after the directory, path_to_dataset/**, to ensure that create_dataset.py recursively grabs the midi files from the dataset. If you forget to include the '**'s they will be added anyway.

train_model.py

The models uses questions.txt and answers.txt dataset to set up vocabulary for encoding and decoding. It returns encoded questions and answers, and a vocabulary table.

After the questions.txt and answers.txt text files have been generated from create_dataset.py, you can run train_model.py to train the model. Run

python train_model.py <model_name>

python train_model.py my_model

to train a model with the name <model_name>.

generate.py

Takes a list of music elements from the output of the model and converts them to rest, chord or note objects. It returns a midi file.

Once you have a trained model you can use generate.py to create a song. Run

python generate.py <model_name>

python generate.py my_model

where the <model_name> is the already trained model.

A random sequence of five notes will be chosen from either answers.txt or questions.txt and be used to start the generation of a song. The song will be stored in a file called test.midi which can be played using either timidity or Windows Media Player.

Playing a MIDI

For our project we used timidity to play our midi files.

These instructions will assume you have Ubuntu or Mac OS X.

Install Timidity

If you are running Ubuntu, you can just paste the following command into your terminal.

sudo apt-get install timidity timidity-interfaces-extra

If you are running Mac OS X, you can just paste the following command into your terminal.

brew install timidity

Play Midi File

timidity <midi file>

Our Demo

IMAGE ALT TEXT HERE

Team Members

Dalton Sumrall, Trase Westbrook, Austin Carpenter, Cassidy Matousek, Soe Than, Julia Vasquez

musicgeneration-pianomusic's People

Contributors

amandanko avatar cassidymatousek avatar fiq362 avatar jvasquez21 avatar krakencode avatar soethanv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

musicgeneration-pianomusic's Issues

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.