X

Google Doodle taps AI to unleash your inner Bach

Harmonizing in the style of the great Baroque composer made easy, thanks to machine learning.

Steven Musil Night Editor / News
Steven Musil is the night news editor at CNET News. He's been hooked on tech since learning BASIC in the late '70s. When not cleaning up after his daughter and son, Steven can be found pedaling around the San Francisco Bay Area. Before joining CNET in 2000, Steven spent 10 years at various Bay Area newspapers.
Expertise I have more than 30 years' experience in journalism in the heart of the Silicon Valley.
Steven Musil
3 min read

Harmonize with Johann Sebastian Bach.

Google

If you've ever listened to classical music and thought, "I could write that," Google has the key to your success.

To mark the 354th birthday of renowned German composer Johann Sebastian Bach, Google on Thursday launched its first-ever artificial intelligence-powered Doodle, which harmonizes a melody of your own creation into Bach's Baroque style of music. Widely regarded as one of the world's greatest composers, Bach produced hundreds of compositions, including cantatas, concertos, suites and chorales, over his lifetime.

Bach already had a great deal of musical knowledge close at hand when he was born in Eisenach, Germany, in 1685. His family included 50 known musicians and several notable composers.

But you and I most likely need a little help to create compositions that sound like Bach's Art of Fugue or Brandenburg Concertos. So Google used machine learning to analyze more than 300 Bach compositions, and with the push of a button, the Doodle will use what it's learned to transform your two-measure melody into Bach's signature style.

Composing Bach, made easy with machine learning.

Google

Within the interactive experience, you can start with simple existing melodies, change the key of the composition and even listen to your composition with a modern rock twist.

The use of AI is spreading like wildfire across the tech industry for everything from speech recognition to spam filtering. The term generally refers to technology called machine learning or to neural networks that are loosely modeled on the human brain. Once you've trained a neural network with real-world data, it can, for example, learn to spot a spam email, transcribe your spoken words into a text message or recognize a cat.

Helping out the Google Doodle team on this project were Google's Magenta and PAIR teams. Magenta is an artificial intelligence effort to create original music and visual art, while PAIR (People + AI Research Initiative) examines the relationship between humans and artificial intelligence in the hopes of making the latter more useful to the former.

The task of creating a machine learning model to power the Doodle fell to Anna Huang, an AI resident with Magenta. She developed Coconet, a model that can perform a wide range of musical tasks, such as harmonizing melodies, smoothing transitions between disconnected fragments of music and composing from scratch.

Coconet was then trained to match Bach's musical style on 306 of Bach's chorale harmonizations. Bach's chorales always have four voices (soprano, alto, tenor and bass) that create a rich harmonic progression when played together. The nature of this structure made for good training data for the model, allowing Coconet to harmonize your melody in Bach's specific style. Google shared more about the process in a "Behind the Doodle" video.  

This isn't the first time a Google Doodle has let us fiddle with virtual music. In 2011, Google celebrated the musician and electric-guitar innovator Les Paul with a playable and recordable guitar. A year later, Google gave us a virtual synthesizer to celebrate American engineer and electronic music pioneer Robert Moog.

But this was a much larger undertaking, requiring much greater resources. Machine learning typically occurs on a lot of servers, with information being sent from a user's computer to a data center and back to the user's computer.

To better handle all the back and forth that would be generated by the interactive Doodle, the PAIR team used TensorFlow.js, a JavaScript library that allows machine learning to occur on the user's browser. For computers not fast enough to run the Doodle on TensorFlow.js, Google's TPUs (tensor processing units) are used to serve up the Doodle. This is the first time the custom processors that speed up AI tasks have been used in a Doodle.

Take note: When your composition is harmonized in Bach's style, you'll have the option of sharing it with friends and even giving it feedback on your masterpiece, which will help improve the machine's performance.

The Doodle will remain on Google's search page for two days in most of the places it's appearing.

Our Favorite Google Doodles Through the Years

See all photos

Originally published March 20.
Update, March 21: Adds "Behind the Doodle" video from Google.