A Hacker’s Delight

Joshua Guenther
Freetail Hackers
Published in
5 min readJul 25, 2017

“It’s kind of fun to do the impossible.” — Walt Disney

Omar Olivarez, MIS and BHP senior at UT Austin. smiles for a portrait at Music Hacks.

Meet Omar Olivarez — a senior at the University of Texas studying Management Information Systems and participant of the Business Honors Program. Omar enjoys a good challenge. Through his participation in Case Competitions, where teams tackle real-world consulting scenarios, he is advancing his understanding of the business realm. Add to this his pursuit of a Computer Science certificate and he is thrilled to take on the challenges presented by Freetail Hackers.

Chill, friendly, and collaborative — these are the words Omar heard from his friend about HackTX. Deliberating on his experiences from Case Competitions, he was excited to attend his first hackathon. Forming a team of four, they crafted a program to data mine Facebook profiles, performing sentiment analysis and extrapolating the level of depression a person is experiencing from them. Integrating the application with Alexa for ease of use, the project won the award for best program to solve online harassment at HackTX in 2016.

“Moodify is a tool for creating a playlist that allows listeners to progress toward a more positive mood.” — Indigitous

With a mindset geared towards problem solving, Omar sought other hackathon experiences and gravitated towards expanding upon sentiment analysis. At the international Indigitious Hackathon, his team created Moodify. Through IBM Watson’s Tone Analyzer API and the Gensim Python package, their web-app categorized songs on a mood spectrum and generated a playlist that strived to transition a listener from a melancholy to an upbeat mood using Latent Dirichlet Allocation. Looking forward, the team saw applications of their mood analysis and song tagging methods in improving the accuracy of recommendation engines. Overall, their effort earned them the hackathon’s Best Technology Award.

Eventually, the hackathons brought Omar full circle. “…a 12-hour hackathon. We’re bringing music and tech together.” read the pixels on Omar’s laptop screen. Music Hacks was official — Freetail Hacker’s would be hosting a music themed hackathon. This presented Omar another exciting opportunity to leverage the universal language.

Omar envisioned a method to fluidly mashup songs at Music Hacks. However, after developing a team of three, he decided on a different idea — programmatically generating music. Through natural language processing (NLP), the team hoped to analyze the parts of speech of lyrics and map them to music notes. Putting all the words of a sentence together and manipulating the notes based on the punctuation of the sentence, they were curious how enjoyable the output would be.

Omar having a laugh with his team during the design phase of their hack.

Bringing the idea to life, the team split up to research technologies. Assessing Apple’s MusicKit and Python’s Winsound, they decide to simplify the problem and work with PySynth. This simple package consists of a set of synthesizers that are designed to mimic different instruments. The initial script, PySynth A blends the sounds of a flute and an organ. In comparison, PySynth B is more complex and leverages NumPy to yield sounds close to a piano. Having selected a tool to convert notes to sound, they now needed to begin mapping words to notes.

While the possibilities of NLP are astounding, the team realized that they would not meet the presentation deadline as time began to dwindle. To catch up, the team reassessed their goal and decided to keep the mapping simple. First their program would parse the input to generate a set containing only unique words and then randomly assign a music note to each entry. Parsing through the lyrics a second time, the program processed the words in order and output the corresponding note.

The program developed quickly as a makemusic.py file was created, PySynth was imported, the business logic was written, and user controls in the terminal were included. Having completed integrations, the team needed lyrics to run through the program. Why not pick your favorite song and let the software perform its magic? The team contemplated this, but decided to select poems as the input. Poems are shorter in word count than most songs and therefore, would lead to the generation of shorter songs. Additionally, poems typically contain more distinct word patterns and they believed that this would produce better quality songs.

Sorting through troves of poems online, the team fell back on their motto — “keep it simple.” Typing D-R- -S-E-U-S-S into their search engineer, the auto populate feature assisted the rest of the way in finding their poem of choice. “The sun did not shine. It was too wet to play. So we sat in the house all that cold, cold, wet day” read a selection of text from The Cat in The Hat.

Feeding the poem into their Python program, a mapping of notes to words was generated that yielded an intriguing tune. Each line of the poem generated a unique pattern in the audio and ended with a defining tone. Comprised solely of eighth notes followed by brief rests, the song rang at a consistent rhythm. They did it! While their implementation changed throughout the hackathon, their overall goal did not. They programmatically generated music.

The heavy lifting was over and it was time to demo. “The Music in Written Word” read the title of their presentation. Talking through their main points with a judge, they opened a terminal and allowed the judge to generate music from a range of pre-selected poems. While the application didn’t meet their initial requirements, they highlighted future improvements to the judge. They could expand the generator to use a dynamic range of notes and beats to be more musically composed. Additionally, Omar envisioned applying sentiment analysis to lyrics and correlating the mood of a sentence to the feel of the audio.

When the judging concluded, it wasn’t the ranking that mattered. Omar was excited to have worked with music. The biggest challenge they faced was choosing an audio library and configuring it to work with their environments. Working through 12 hours of setup and roadblocks, he finally generated music through code. Adding to the experience, Omar’s teammates had minimal coding knowledge. Omar really wanted his teammates to get as much enjoyment out of hackathons as he did. Stepping away from the keyboard, his team’s inexperience allowed him to drive fun discussions around design and offer them first-hand experience programming.

Github Repo: The Music in Written Word

--

--

Joshua Guenther
Freetail Hackers

Dog Lover. Photographer. Journalist. Computer Scientist.