Skip to content

Generating Irish folk music in ABC notation using an LSTM Recurrent Neural Network (RNN) implemented with PyTorch.

Notifications You must be signed in to change notification settings

Ahmonemb/RNN-Music-Generation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

RNN Music Generation

📜 Abstract

This project explores the generation of novel musical sequences in the style of Irish folk music using a Recurrent Neural Network (RNN), specifically an LSTM (Long Short-Term Memory) network. The model is trained on a dataset of Irish folk songs represented in ABC notation and learns to predict subsequent characters in the sequence, enabling the generation of new compositions. The implementation uses PyTorch, and experiment tracking is managed with Comet ML.

🎯 Motivation

Algorithmic music generation is a fascinating intersection of artificial intelligence and creativity. This project aims to:

  • Understand how RNNs can capture sequential patterns and structures inherent in musical notation.
  • Develop a model capable of generating coherent and stylistically appropriate musical pieces.
  • Explore the use of ABC notation as a compact and effective representation for symbolic music generation.

🧠 Approach

  1. Data Representation: Music is represented using ABC notation, a text-based format commonly used for folk and traditional tunes.
  2. Preprocessing: The ABC notation dataset is preprocessed by concatenating tunes, creating character-to-integer mappings, and vectorizing the sequences into numerical format suitable for the RNN.
  3. Model Architecture: An LSTM-based RNN is implemented using PyTorch. LSTMs are well-suited for capturing long-range dependencies found in sequential data like music.
  4. Training: The model is trained using backpropagation through time to predict the next character in a sequence given the preceding characters. The Adam optimizer and Cross-Entropy Loss function are used. Comet ML is integrated for logging metrics, hyperparameters, and model checkpoints during training.
  5. Generation: New musical sequences are generated by providing the trained model with a seed sequence (a starting string of characters) and iteratively sampling from the model's output probability distribution for the next character. Multinomial sampling is used to introduce variability.
  6. Output: The generated character sequences represent new musical pieces in ABC notation. These can be optionally converted to audible formats (like MIDI or WAV) using external tools.

📊 Dataset

  • Dataset: A collection of Irish folk songs in ABC notation. (Specify the source if known, e.g., "sourced from [Website/Collection Name]").
  • Preprocessing: [Briefly mention key steps like concatenation, vocabulary creation, sequence chunking, vectorization].

⚙️ Setup & Installation

  1. Clone the repository:

    git clone https://github.com/[your-username]/[your-repo-name].git
    cd [your-repo-name]
  2. (Recommended) Create a virtual environment:

    python -m venv venv
    source venv/bin/activate  # Linux/macOS
    # venv\Scripts\activate  # Windows
  3. Install dependencies: (Choose one based on your project)

    pip install -r requirements.txt

    or

    conda env create -f environment.yml
    conda activate [your-env-name]

    Ensure requirements.txt or environment.yml includes torch, numpy, comet_ml, etc.

  4. Comet ML Setup:

    • Sign up for a free account at Comet.ml.
    • Configure your API key. You can do this by setting environment variables or creating a .comet.config file:
      [comet]
      api_key = YOUR_API_KEY
      project_name = YOUR_PROJECT_NAME
      workspace = YOUR_WORKSPACE
  5. Dataset: [Provide instructions on where to place the dataset file(s), e.g., data/irish_folk_tunes.abc].

▶️ Usage

Training the RNN Model

To train the music generation model, run:

python train_rnn.py --data_path data/irish_folk_tunes.abc --config configs/rnn_config.yaml --output_dir ./models/music_rnn

About

Generating Irish folk music in ABC notation using an LSTM Recurrent Neural Network (RNN) implemented with PyTorch.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published