Example #1
0
def handle_dial_a_spam():
    recording = spam.get_next_recording()
    resp = twilio.twiml.Response()
    resp.play(recording["url"])
    return str(resp)
Example #2
0
def next_recording():
    return json.dumps(spam.get_next_recording())
Example #3
0
def play_a_spam():
    recording_url = spam.get_next_recording()["url"] + ".mp3"
    return render_template("play_a_spam.html", recording_url=recording_url)
Example #4
0
import OSC

logging.basicConfig(level=logging.INFO)
log = logging.getLogger(__name__)

TIMEOUT = 10*1000

def _play_command(url):
    return ["mplayer", '-ao', 'jack:name=spambot', url]
    #return ["mplayer", url]

if __name__ == "__main__":

    while(True):
        try:
            recording = spam.get_next_recording()
            log.info("Playing %s" % (recording["spam_id"]))
            mp3_url = "%s.mp3" % recording["url"]
            topic = recording["topic"]
            
            if topic in ["sex", "money"]:
                log.info("Sending %s osc message" % (recording["topic"]))
                c = OSC.OSCClient()
                c.sendto(OSC.OSCMessage("/%s" % topic), ("localhost",9998), 10)
                time.sleep(5)
            else:
                c.sendto(OSC.OSCMessage("/neutral"), ("localhost",9998), 10)
            
            p = subprocess.Popen(_play_command(mp3_url))
            starttime = time.time()