Warning: Undefined variable $show_banner in /home/pushpull/liederproject.pushpullfork.com/index.php on line 67

Combining Music Notation with IPA Text

by Kris Shaffer

We've made a lot of progress with our code for The Lieder Project recently. Or, at least since the most recent blog post. :)

One update is a new, short Python script, textMusicCombine.py, which does just what it sounds like it does. It takes poetry from a text file and combines it with music notation from another file — in this case, our music is coming from musicXML files (modified from Leigh VanHandel's amazing **kern database).

There are a couple of tricks to making this work. One is syllabification. I wrote this script to divide the text stream into syllables by looking for new lines, spaces between words, and periods between syllables. We just had to make sure our IPA transcriptions included those periods. So the first two lines of "Am Feierabend"

Hätt ich tausend
Arme zu rühren!

are translated into syllabified IPA like this:

'hɛt Iç 'ta:ʊ.sənt
'aɾ.mə tsu 'ɾy.ɾən

Another issue is ties and slurs — when there are multiple notes in the printed music that need to be attached to a single syllable. Most of the code in textMusicCombine.py is dealing with that scenario. I'm pretty sure that 7 if loops and 2 for loops all nested together is bad form for a programmer, but it works. :p (I'll spare you the details, but if you're interested, simply follow the link and see the code on GitHub.)

Finally, we had originally encoded the poems as poems. But composers often repeat, even change, text when they set a poem to music, and we had to account for that. So we made a second version of each poem that accounted for those changes, and we used those versions as the source text to get the poetry and music lining up properly.

It took a fair bit of back and forth, as Jordan and I looked at the musical scores being produced, finding errors both in the code and in the IPA text. But ultimately, we cleaned up all of the files, and get some usable results. And now, we have a program that anyone (with Python and music21 installed) can use for combining a plain-text poem with music notation. Since our script is based around the musicXML format, which just about every music notation program can import/export, we hope it will be useful to many others. (And we hope that if others use it, they'll notify us of newly found kinks for us to work out!)

Here's a sample of what it produced:

You can find all the output we've created so far, including the entire set of vocal parts for Die schöne Müllerin, here. If any vocalists need an IPA version of those songs, download away!