The Music Composed By An Algorithm Analysing The World’s Best Novels
Sit back and listen to the music generated by a computer program that measures the “emotional temperature” of novels
The automatic analysis of sentiment in text is fast changing the way we interpret and interact with words. On Twitter, for example, researchers have begun to gauge the mood of entire nations by analysing the emotional content of the tweets people generate.
In the same way, other researchers have started to measure the “emotional temperature” of novels by counting the density of words associated with the eight basic emotions of anticipation, anger, joy, fear, disgust, sadness, surprise and trust.
All this automation is possible thanks to new databases that rate words according to their emotional value.
Now Hannah Davis at New York University and Saif Mohammad at the National Research Council Canada have gone a step further. These guys have used the same kind of analysis to measure the way the emotional temperature changes throughout a novels and then automatically generated music that reflects these moods and how they evolve throughout the book.
They say their new algorithm, TransProse, will change the way we interact with information. “The work has applications in information visualization, in creating audio-visual e-books, and in developing music apps,” they say.
The algorithm has three steps, each straightforward in concept. First, it divides the book into four parts—the beginning, early middle, late middle and ending— and then generates an emotion profile for each section. This is simply a set of statistics describing the way different emotions rise and fall throughout that section.
Next, the algorithm uses these emotions to generate the background music for that section. This is the tricky part. “The challenge in composing new music, just as in creating a new story, is the infinite number of choices and possibilities,” say Davis and Mohammad.
But these guys have made a decent stab of automating this process. They’ve done it by developing a number of mapping rules to determine various elements of music, such as tempo, major/minor key and so on. according to the density of words representing different emotions in the text.
What’s more, the algorithm determines the sequence of notes—pitch and duration pairs—as the emotion word density changes in the text. And they’ve found a way to link these notes together so that it sounds like music rather than a sequence of noises.
There are one or two shortcuts, of course. For example, they stick only to the C major and C minor keys and do not switch keys during a melody.
The resulting pieces consist of a dominant melody determined by the dominant emotion but accompanied by secondary and tertiary melodies generated by other emotions that are also present.
Finally, they convert the resulting sequence of notes into a sound file of piano music using a standard open source program called JFugue.
The best way to judge the results is to listen to them. Davis and Mohammad have used TransProse to generate music for a variety of well known novels such as A Clockwork Orange, The Heart of Darkness, The Road and Peter Pan among others. And they’ve put the results on the web at http://transprose.weebly.com/final-pieces.html.
Take a listen. I’ve embedded some of the melodies here and the results are surprisingly good.
The potential applications are numerous. Davis and Mohammad say they could create audio-visual e-books that generate music that reflects the mood on pages that are opened.
They imagine generating music for movie scripts. It may even be possible to generate short melodies to warn users about the emotional content of tweets they receive.
But perhaps most interesting is the possibility of finding songs that best capture the emotions in different parts of the novel. That would require a kind of inverse TransProse—a way of analysing the emotional content of music and mapping it onto a book.
So there’s potential. We’ll wait eagerly for this musical future.
Ref: arxiv.org/abs/1403.2124 : Generating Music from Literature