Two days before ITP begins, and this is what I’m currently working on: computer generated poetry, read by a computer and accompanied by computer-selected images related to the text.
I call it Poetizer, I coded it in Python, and it works with any text corpus. It’s also modular, so you can use the poetry-reading (poemreader.py) parts and poetry-writing parts (poetizer.py) separately to generate derivative works.
All of this started with Sonnetizer, a computer program I wrote that generates sonnets from any text corpus in (mostly) iambic pentameter using Ngram-based natural language generation (via NLTK) along with rhyming and metrical rules. You can view the code on GitHub or check out this book of 10,000 sonnets (warning: 5000-page PDF) generated from the sonnets of William Shakespeare.
Sonnetizer was my first major Python project, and building it taught me a lot about Python. However, after building it and letting it sit for a month or so, I began to think about ways I might improve it.
Poetizer.py is the result of that process. It involves user inputs such as rhyme scheme and desired poetic structure to allow for interactive poetry generation.
Poemreader.py reads poems using built-in text-to-speech utilities present on Mac and Linux machines. It also displays images, gathered via Flickr API, related to the words in each poem it reads.
Main.py is a combination of the two files, tuned to produce a distinct interactive poetry experience. (This is the script running in the video above.)