Ecstatic Virtual Poetry
For the first project in Designing Interfaces for Live Performance, we were assigned to create a project based on three randomly generated words by the professor. My group-mate Mostafa and I were assigned the term "Ecstatic Virtual Poetry."
We chose to create a novel poetry performance in which the users have input into the final digital result. While this decision rendered the 'virtual poem' requirement of the prompt satisfied, there was still quite a bit of uncertainty around how to make the experience 'ecstatic'. In the end, this guideline was attempted through a combination of energetic P5 graphics and the replacement of most punctuation with exclamation marks.
This is accomplished through a Node server running on Glitch, which communicates over WebSockets to a dashboard client, an output client, and all other mobile/desktop 'voter' clients. All data from votes gets sent through the server to the dashboard, where the person in charge of the performance can tell the server to start the Python script with the current input and then subsequently send the result to the output client.
Poem Generation
At the heart of the performance is the live generation of a new poem from a corpus of user-selected poetry. This adds novelty and immersion through interactivity to every performance, and can be manipulated readily through changing what source material the users are able to select. When the user is a part of the generation of the performance, even if only marginally, I feel that there is a greater sense of attachment to the end result.
In terms of the technical process, the generation is done by Markov chain in a Python script. Mostafa did the majority of work on this end, allowing it to be hooked right up to a Node server running the Python Shell plugin. Here is an example of the code that enables the chaining:
for word in poems[index:]:
key = poems[index - 1]
if key in chain:
chain[key].append(word)
else:
chain[key] = [word]
index += 1
word1 = random.choice(list(chain.keys()))
message = word1.capitalize()
while len(message.split(' ')) < count:
word2 = random.choice(chain[word1])
word1 = word2
message += ' ' + word2
And the code used to run the Python script from the Node server:
async function generatePoem(corpus){
// Python shell setup
let options = {
args: [corpus]
};
// Start python shell
const pyshell = new PythonShell('public/python/script.py', options);
pyshell.on('message', message => {
// received a message sent from the Python script (a simple "print" statement)
messageArray.push(message);
});
pyshell.end(err => {
if (err){
throw err
} else {
console.log("Script execution complete")
outputs.emit('poemText', messageArray);
}
});
};
For example, here is some input text from a couple user-selected poems:
1 Shall I compare thee to a summer’s day? Thou art more lovely and more temperate: Rough winds do shake the darling buds of May, And summer’s lease hath all too short a date: Sometime too hot the eye of heaven shines, And often is his gold complexion dimm’d; And every fair from fair sometime declines, By chance, or nature’s changing course, untrimm’d; But thy eternal summer shall not fade Nor lose possession of that fair thou ow’st; Nor shall Death brag thou wander’st in his shade, When in eternal lines to time thou grow’st; So long as men can breathe or eyes can see, So long lives this, and this gives life to thee. 2 If those I loved were lost The Crier's voice would tell me -- If those I loved were found The bells of Ghent would ring -- Did those I loved repose The Daisy would impel me. Philip -- when bewildered Bore his riddle in!
And here's the output:
Breathe or nature’s changing course!
But thy eternal summer shall Death brag thou wander’st in eternal lines to a summer’s lease hath all too short a date!
Sometime too short a date!
Sometime too hot the darling buds of Ghent would ring --
Did those I compare thee to a date!
Sometime too short a date!
Sometime too hot the darling buds of May!
And summer’s lease hath all too short a summer’s day?
Thou art more lovely and this gives life to a summer’s lease hath all too hot the darling buds of heaven shines!
And often is his gold complexion dimm’d!
And every fair from fair sometime