12.  Melody Generation with Markov Chains - Generative Music AI @ValerioVelardoTheSoundofAI
12.  Melody Generation with Markov Chains - Generative Music AI  @ValerioVelardoTheSoundofAI
Uploaded November 2023 | Updated September 2026, 2 weeks ago
We implement a Markov chain to generate melodies in Python.

Get code:
github.com/musikalkemist/generativemusicaicourse/blob/main/12.%20Melody%20generation%20with%20Markov%20chains/Code/markovchain.py

Get the lecture slides:
github.com/musikalkemist/generativemusicaicourse/blob/main/12.%20Melody%20generation%20with%20Markov%20chains/Slides/12.%20Melody%20generation%20with%20Markov%20chains.pdf

Website of the Generative Music AI Workshop in Barcelona:
https://www.upf.edu/web/mtg/generative-music-ai-workshop

Sign up to The Sound of AI Slack Community to join the discussion:
valeriovelardo.com/the-sound-of-ai-community

======================================

Interested in music AI consulting?
thesoundofai.com/consulting.html

Interested in music AI recruitment?
thesoundofai.com/recruitment.html

Become a Python ninja with my Advanced Python Programming course:
the-sound-of-ai-academy.teachable.com/p/advanced-python-programming

Connect with Valerio on LinkedIn:
linkedin.com/in/valeriovelardo

Follow Valerio on Twitter:
twitter.com/musikalkemist

======================================

Content
0:00 Intro
1:35 Running the script + melody example
2:48 Main function
3:52 MarkovChainMelodyGenerator
6:50 Train method
17:27 Generate method
25:24 Revisiting the main function
28:00 Possible code expansions
30:09 What next?
12.  Melody Generation with Markov Chains - Generative Music AIPreparing the Speech DatasetThe Secrets to Fail/Succeed Building a Machine Learning Solution7 Real-World AI Audio Applications6. Symbolic Vs Audio Generation - Generative Music AI7. Generative Techniques - Generative Music AIExtracting Mel-Frequency Cepstral Coefficients with PythonHiring recent audio AI graduates. Good or bad idea?Is Your Company Ready to Adopt AI?Pre-processing Audio with Different DurationsJoin the hackathon!22.  Text-To-Music Generation with Mustango - Generative Music AI
Valerio Velardo - The Sound of AI |

12. Melody Generation with Markov Chains - Generative Music AI

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER