Skip to main content

A module for pre-processing steps in music generation

Project description

# musicgen musicgen is a module for pre-processing audio and to prepare the dataset for neural networks in genarating music. Built on top of Music21 and youtube_dl


  • Download the songs,videos from URL
  • Get the notes from music
  • Prepare the dataset for neural networks


$ pip install musicgen


Get all the notes and chords from the midi files


path : path for the song with midi extension. ‘*.mid’ by default which gets the note of all the songs in the current working directory.


List of notes obtained from the midi file


Downloads the audio of a video present in the given video URL to current working directory.


url : (string) URL of a video
audio_type :(string)"aac", "flac", "mp3", "m4a", "opus", "vorbis", or "wav". ‘mp3’ by default


convert the output from the prediction to notes and create a midi file from the notes in current working directory.


prediction_output : the output predictions of a trained model.
name : (string) name of the generated file. output by default.

prepare_sequences(notes, n_vocab,sequence_length = 100)

Prepare the sequences used by the Neural Network


notes : (list) notes of midi file
n_vocab : (int) number of unique notes
sequence_length : (int) number of time steps required. 100 by default.


network_input, network_output


Downloads the video from the given URL into current working directory.


url : (string) URL of a video


Downloads the videos from the URL’s present in a text file into current working directory.


path : (string) path of a text file containing URL’s


Downloads the audio of videos from the URL’s present in a text file into current working directory.


path : (string) path of a text file containing URL’s.


saves the notes of a midi file as a pickle object.


path : (string) path of the songs
output : (string) name of the pickle file.

generate_notes(model, network_input, pitchnames, n_vocab)

generates the notes from the trained keras model


model : Trained keras model for prediction
network_input : input to the network
pitchnames : set of items in the notes. It is found using pitchnames = sorted(set(item for item in notes))
n_vocab : (int) number of unique notes



Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for musicgen, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size musicgen-0.0.1.tar.gz (4.6 kB) File type Source Python version None Upload date Hashes View
Filename, size musicgen-0.0.1-py3-none-any.whl (5.7 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page