August 2, 2010

Sleep Superbly – Sleep Therapy

Sleep Therapy
I’ve just wrapped up the final touches on an interesting new project that launched sometime last week. http://sleepsuperbly.com has a campaign going on involving a faux sleep analysis, and it was Oddcast’s task to build the application. Combining several of our technologies, both new and old, you are lead through a series of questions customized according to your own Facebook information (if you allow the application to access it). Your host is a talking 3D avatar who reads a text-to-speech script to you injected full of your interests, hometown location, the most recent friend to post to your wall, and other fun facts that it should not otherwise know. In order to keep the experience as engaging as possible, the whole time you will be staring more or less intro your eyes via a webcam, which is also how you answer questions; the application continues to analyze and track the location of your face within the webcam, and listens to your answer – yes or no – in the form of blinking.

This project kept me on my toes, since, as always, it was a rush deadline with less than cooperative clients (par for the course in the advertising world), and involved quite a few heavy little pieces that had to work in conjunction with one another programmatically. Code-wise, there is quite a lot asynchronous execution, and challenging conditions where we need maintain a smooth experience where in reality the state of the application under the hood is convoluted. Something I rolled out as a convenience for myself during development is a basic scripting language runtime interpreter. Although more robust solutions exist, it was fun to get elbows deep in tokenization, parse trees and interpreting. Essentially each question in the sleep analysis needs to be validated against certain conditions using Facebook info (are you male, do you have a wife, etc), so that you are not asked something irrelevant about makeup if you are a guy. Using my interpreter, I was able to keep such conditions as strings of script within the same xml file that the questions themselves were stored, and evaluate them at runtime without re-publishing the swf. For example:

<question>
        <value>Do you feel that, lately, things with your wife {SPOUSE_NAME} have been going smoothly?</value>
       <condition>{relationship_status} == {MARRIED} && {gender} == {MALE}</condition>
</question>

So go and check it out at the official site, or as hosted by Oddcast should the Sleep Superbly campaign end. Enjoy!