SlideShare a Scribd company logo
1 of 36
Algorithmic
Music Generation
PADMAJA V BHAGWAT
www.linkedin.com/in/padmajavb 01
02
#Junior
#Bachelors
#Art
#Music
#Dance
#Technology
03
sample #1
sample #2
Can you
tell the
difference?
04
How to
make
computer
generate
music?
Step 1: Convert Mp3 files to np-tensors
Step 2:Train the model
Step 3: Generate the music
05
Uncompress
the music:
mp3 to
monaural
WAV using
LAME cmd = 'lame -a -m m {0} {1}'.format(
quote(filename), quote(filename_tmp))
06
Convert to
Numpy
array
These are divided into blocks of equal
size by zero padding it.
07
Convert
from time to
frequency
domain
Convert from the time domain
to its corresponding frequency
domain using a Discrete
FourierTransform.
08
fft_block = np.fft.fft(block)
What model to use?
09
Can we use
traditional
Machine
Learning
algorithm?
10
Neural networks…
11
We’ll go with RNN...
12
* http://colah.github.io/posts/2015-08-Understanding-LSTMs/
Can we
make it
remember
for longer
period of
time?
Yes we can! By using
LSTM networks.
13
* http://colah.github.io/posts/2015-08-Understanding-LSTMs/
What are
LSTM
Networks?
14
Long
Short
Term
Memory
Let’s
understand
its
architecture
.
15
* http://deeplearning.net/tutorial/lstm.html
This is how it looks!
Who carries the
legacy??
-cell state
16
* http://colah.github.io/posts/2015-08-Understanding-LSTMs/
Step 1 Deciding what to throw
away;
Who does that?
- forget gate layer
17
* http://colah.github.io/posts/2015-08-Understanding-LSTMs/
Step 2
Deciding what to
update;
Who does that?
-Input gate layer
&
-tanh layer
18
* http://colah.github.io/posts/2015-08-Understanding-LSTMs/
Step 3
old cell state Ct-1 new cell state Ct
19
* http://colah.github.io/posts/2015-08-Understanding-LSTMs/
Step 4 Deciding the output;
Who does that?
-Sigmoid layer
20
* http://colah.github.io/posts/2015-08-Understanding-LSTMs/
How to code
all this??
21
How to do it with Python?
from keras.layers.recurrent import LSTM # import LSTM network
from keras.models import Sequential # import Sequential model
model = Sequential() # instantiate model
# add LSTM layer to the model
model.add(LSTM(input_dim = num_hidden_dimensions,
output_dim=num_hidden_dimensions, return_sequences=True))
22
Training
the
model
Optimizer – ‘rms-prop’
Loss function – ‘mean squared error’
23
* http://sebastianruder.com/optimizing-gradient-descent/
Train the model
while cur_iter < num_iters:
# Iterate over the training data in batches
history = model.fit(X_train, y_train,
batch_size=batch_size, nb_epoch=epochs_per_iter,
verbose=1, validation_split=0.0)
cur_iter += epochs_per_iter
24
Generation
phase
A = [X0, X1, ... Xn]
Predict Xn + 1Append Xn + 1 to A
25
# We take first chunk of the training data as a seed sequence
seed_seq = seed_generator.generate_copy_seed_sequence(seed_length=seed_len,
training_data=X_train)
# This defines how long the final song is. Total song length in samples = max_seq_len * example_len
output = sequence_generator.generate_from_seed(model=model, seed=seed_seq,
sequence_length=max_seq_len)
26
Generate the music
Challenges! Challenges! Challenges!
27
Data
intensive
28
Memory
intensive
29
0
0.5
1
1.5
2
2.5
3
3.5
Tensors
Memory Consumed in GB
10 20 50
AWS instance:
t2.2xlarge:
32 GiB of memory
8 vCPUs
EBS-only
64 bit platform
Time intensive
4
18
72
0.7
3.5
14
0
10
20
30
40
50
60
70
80
100 500 2000
TIIME
ITERATIONS
CPU GPU
30
How long does it take?
After about 100 iterations
over 20 different music files.
2231
# Parameters
num_iters = 100
epochs_per_iter = 25
batch_size = 5
After 2000 iterations over 20
different music files.
Well it takes time…
# Parameters
num_iters = 2000
epochs_per_iter = 25
batch_size = 5
32
Python
Libraries
used
• LAME and SoX to convert mp3 files
into other formats such as wav.
• NumPy and SciPy for various
mathematical computation on
tensors.
• Matplotlib for visualizing the input.
• Keras version 0.1.0 with Theano as
the backend.
33
The entire code is on GitHub
https://github.com/unnati-xyz/music-generation
34
Key notes
for using
this code to
generate
your own
music
Step 1: Convert given mp3 files into np
tensors.
python convert_directory.py
# converts mp3 files to numpy tensors
Step 2: Train the model.
python train.py # creates LSTM model
Step 3: Generate the music.
python generate.py # final generated music which is
stored in a file named generated_song.wav.
35
Unnati Data
Labswww.unnati.xyz
Mentors: Nischal HP, Bargava Subramanian, Amit Kapoor, Raghotam Sripadraj
Team: Chandana NT, Anirudh Sriram, Subramaniam Thirunavakkarasu
Thank you!
https://github.com/PadmajaVB

More Related Content

What's hot

What's hot (11)

Introduction to Data-Oriented Design
Introduction to Data-Oriented DesignIntroduction to Data-Oriented Design
Introduction to Data-Oriented Design
 
Martin Takac - “Solving Large-Scale Machine Learning Problems in a Distribute...
Martin Takac - “Solving Large-Scale Machine Learning Problems in a Distribute...Martin Takac - “Solving Large-Scale Machine Learning Problems in a Distribute...
Martin Takac - “Solving Large-Scale Machine Learning Problems in a Distribute...
 
Accelerating microbiome research with OpenACC
Accelerating microbiome research with OpenACCAccelerating microbiome research with OpenACC
Accelerating microbiome research with OpenACC
 
Fann tool users_guide
Fann tool users_guideFann tool users_guide
Fann tool users_guide
 
Tensor flow
Tensor flowTensor flow
Tensor flow
 
Rajat Monga at AI Frontiers: Deep Learning with TensorFlow
Rajat Monga at AI Frontiers: Deep Learning with TensorFlowRajat Monga at AI Frontiers: Deep Learning with TensorFlow
Rajat Monga at AI Frontiers: Deep Learning with TensorFlow
 
#GDC15 Code Clinic
#GDC15 Code Clinic#GDC15 Code Clinic
#GDC15 Code Clinic
 
Using Multi GPU in PyTorch
Using Multi GPU in PyTorchUsing Multi GPU in PyTorch
Using Multi GPU in PyTorch
 
The method of comparing two audio files
The method of comparing two audio filesThe method of comparing two audio files
The method of comparing two audio files
 
Teaching Recurrent Neural Networks using Tensorflow (May 2016)
Teaching Recurrent Neural Networks using Tensorflow (May 2016)Teaching Recurrent Neural Networks using Tensorflow (May 2016)
Teaching Recurrent Neural Networks using Tensorflow (May 2016)
 
Learning Financial Market Data with Recurrent Autoencoders and TensorFlow
Learning Financial Market Data with Recurrent Autoencoders and TensorFlowLearning Financial Market Data with Recurrent Autoencoders and TensorFlow
Learning Financial Market Data with Recurrent Autoencoders and TensorFlow
 

Similar to Algorithmic Music Generation

Operating System 4 1193308760782240 2
Operating System 4 1193308760782240 2Operating System 4 1193308760782240 2
Operating System 4 1193308760782240 2
mona_hakmy
 
Operating System 4
Operating System 4Operating System 4
Operating System 4
tech2click
 
Software development slides
Software development slidesSoftware development slides
Software development slides
iarthur
 
Utp pds_l4_procesamiento de señales del habla con mat_lab
 Utp pds_l4_procesamiento de señales del habla con mat_lab Utp pds_l4_procesamiento de señales del habla con mat_lab
Utp pds_l4_procesamiento de señales del habla con mat_lab
jcbenitezp
 

Similar to Algorithmic Music Generation (20)

TinyML - 4 speech recognition
TinyML - 4 speech recognition TinyML - 4 speech recognition
TinyML - 4 speech recognition
 
FORECASTING MUSIC GENRE (RNN - LSTM)
FORECASTING MUSIC GENRE (RNN - LSTM)FORECASTING MUSIC GENRE (RNN - LSTM)
FORECASTING MUSIC GENRE (RNN - LSTM)
 
What Shazam doesn't want you to know
What Shazam doesn't want you to knowWhat Shazam doesn't want you to know
What Shazam doesn't want you to know
 
Architecture Assignment Help
Architecture Assignment HelpArchitecture Assignment Help
Architecture Assignment Help
 
Yufeng Guo - Tensor Processing Units: how TPUs enable the next generation of ...
Yufeng Guo - Tensor Processing Units: how TPUs enable the next generation of ...Yufeng Guo - Tensor Processing Units: how TPUs enable the next generation of ...
Yufeng Guo - Tensor Processing Units: how TPUs enable the next generation of ...
 
Interview questions
Interview questionsInterview questions
Interview questions
 
Mca2050 computer architecture
Mca2050  computer architectureMca2050  computer architecture
Mca2050 computer architecture
 
mlp10-sem2.pdf
mlp10-sem2.pdfmlp10-sem2.pdf
mlp10-sem2.pdf
 
Open power ddl and lms
Open power ddl and lmsOpen power ddl and lms
Open power ddl and lms
 
EEND-SS.pdf
EEND-SS.pdfEEND-SS.pdf
EEND-SS.pdf
 
Tokyo Webmining Talk1
Tokyo Webmining Talk1Tokyo Webmining Talk1
Tokyo Webmining Talk1
 
parallel-computation.pdf
parallel-computation.pdfparallel-computation.pdf
parallel-computation.pdf
 
Mcs 041 assignment solution (2020-21)
Mcs 041 assignment solution (2020-21)Mcs 041 assignment solution (2020-21)
Mcs 041 assignment solution (2020-21)
 
Operating System 4 1193308760782240 2
Operating System 4 1193308760782240 2Operating System 4 1193308760782240 2
Operating System 4 1193308760782240 2
 
Operating System 4
Operating System 4Operating System 4
Operating System 4
 
Software development slides
Software development slidesSoftware development slides
Software development slides
 
Deep Dive on Deep Learning (June 2018)
Deep Dive on Deep Learning (June 2018)Deep Dive on Deep Learning (June 2018)
Deep Dive on Deep Learning (June 2018)
 
Utp pds_l4_procesamiento de señales del habla con mat_lab
 Utp pds_l4_procesamiento de señales del habla con mat_lab Utp pds_l4_procesamiento de señales del habla con mat_lab
Utp pds_l4_procesamiento de señales del habla con mat_lab
 
Parallel computation
Parallel computationParallel computation
Parallel computation
 
maXbox Starter 42 Multiprocessing Programming
maXbox Starter 42 Multiprocessing Programming maXbox Starter 42 Multiprocessing Programming
maXbox Starter 42 Multiprocessing Programming
 

Recently uploaded

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Algorithmic Music Generation