/Music.Generation.with.DeepLearning

Generating Music and Lyrics using Deep Learning via Long Short-Term Recurrent Networks (LSTMs). Implements a Char-RNN in Python using TensorFlow.

Primary LanguageJupyter Notebook

Music.Generation.with.DeepLearning

Generating Irish Folk Tunes and Lyrics - using LSTM¶ This project uses Long Short-term Memory (LSTM) -based recurrent neural network (RNN) to generate music and lyrics using the Irish Folk Music dataset. Additionally, it also generates "Bob Dylan-esque" lyrics, using all of Bob Dylan's songs.

Summary

We use the power of Deep Learning to train LSTM Networks to creatively generate Irish Folk Tunes and Bob Dylan lyrics

Results

TLDR: ![See video on YouTube]

See the video at: here

Write-up

Datasets

Irish Folk Music

As a lover of folk tunes, particularly Irish tunes, I found these datasets immensely helpful.

I wrote a scraper to scrape O'Neill's and Cobb's data from the sites, clean up the data, and combine them in one file.

Bob Dylan Songs

I scraped the Bob Dylan songs site (http://bobdylan.com/songs/), downloaded the lyrics separately and combined them in one text file. It comes down a mere 700KB dataset, which is tiny for the purposes of training an RNN.

For copyright reasons, Bob Dylan's lyrics are not included in this repo.

Char-RNN based Generator

The mechanics of the text generation uses a Char-RNN based generator, as decribed by Andrej Karpathy (http://karpathy.github.io/2015/05/21/rnn-effectiveness/)

To create an RNN, specify the model_type as one 'lstm', 'rnn', or 'gru'. In general, the LSTM type networks have shown to be more effective (per Karpathy)

Specify these params:

  • batch_size: sequences in a mini batch
  • sequence_length: number of characters in a sequence
  • n_cells: number of cells in the (hidden) RNN layers
  • n_layers: number of layers in the RNN
  • ckpt_name: unique name for the model; used to save the model or restore from it
  • learning_rate: how fast or slow the network should learn (typically, 0.001, but can be set to 0.0001)

ABC Music Format

The ABC Music format is a text-based music format.

Here's one such tune, called Julia Delaney in ABC format: [See a youtube sample here: https://www.youtube.com/watch?v=DUZ6zei3fRU]

X:174
T:Julia Delaney
Z: id:dc-reel-161
M:C
L:1/8
K:D Minor
A|dcAG F2DF|E2CE F2DF|dcAG F2DF|Add^c defe|!
dcAG F2DF|E2CE F2DF|dcAG F2DF|Add^c d3:|!
e|fede fagf|ecgc acgc|fede fagf|edcA Adde|!
fede fagf|ecgc acgc|fedf edcA|Add^c d3:|!

As can be seen, the format is incredibly compact. Each line begins with a single letter field (except for notes). ABC notation for music (link: http://abcnotation.com/)

  • X denotes a reference number
  • M denotes Meter
  • K denotes the Key
  • L denotes the beats
  • T denotes the Title
  • Z denotes the transcription The rest are notes that denote the melody for the song.

As one can see, this text data is useful to train an RNN to generate a similarly structed .abc, which can then be converted into .MIDI format, and from there to .WAV or .OGG format to play.

References

A few of the references that helped me. More useful for future work.