Today's Google Doodle uses AI to let you write music in the style of Bach

Ever wanted to write music like Johann Sebastian Bach?

In honour of the composer's 334th birthday, today's Google Doodle uses artificial intelligence to turn a simple melody into a four-part chorale arrangement.

The machine-learning model that powers the Doodle, Coconet, was developed by Anna Huang. She's an AI resident at Google and worked on the project while she was a visiting student at the Montreal Institute of Learning Algorithms.

"I wanted to build a model that could be really flexible so that it could actually support a musician," she said.

Having studied both music composition and computer science, Huang sees the project as a way to combine her two passions.

Coconet can generate sound to bridge two musical ideas, harmonize melodies and identify the key and chord progressions used in a piece of music.

It can also change the way artists write — working alongside an AI program to create music.

Huang's AI was trained on 306 of Bach's chorale arrangements. The AI researcher says the chorales, written for soprano, alto, tenor and bass voices to sing together, work well because they are short, have distinct parts and don't move too quickly.

"They're very concise, but at the same time very rich," she said.

Google

Coconet analyzes a musical score and generates a visual representation of the music that it analyzes for patterns.

To train the AI, the researchers would remove random notes and let the Coconet fill them in, checking to see how close it could get to the original piece.

And once it understood how the harmonies worked, it started creating its own rules based on what it had learned.

The Google Doodle is also a way to make composition accessible, shrinking down the complex machine learning model so that it can work in the average web browser.

It allows people who don't think they can write music to express themselves with the help of a computer.

"We want them to feel empowered," she said.