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.
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.
- Data Representation: Music is represented using ABC notation, a text-based format commonly used for folk and traditional tunes.
- 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.
- 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.
- 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.
- 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.
- 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: 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].
-
Clone the repository:
git clone https://github.com/[your-username]/[your-repo-name].git cd [your-repo-name] -
(Recommended) Create a virtual environment:
python -m venv venv source venv/bin/activate # Linux/macOS # venv\Scripts\activate # Windows
-
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.txtorenvironment.ymlincludestorch,numpy,comet_ml, etc. -
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.configfile:[comet] api_key = YOUR_API_KEY project_name = YOUR_PROJECT_NAME workspace = YOUR_WORKSPACE
-
Dataset: [Provide instructions on where to place the dataset file(s), e.g.,
data/irish_folk_tunes.abc].
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