The goal was to create a Slackbot (using slack.com) that could text-to-speech to the cleanspace on command.

Slack provides an API for automated agents (bots) and there are many ways to access the API as found here. I looked at several of the Python examples and settled on Slask as most appropriate for the job.  It is very simple, well organized and easily extendible without changing any of the existing code.


The hardware for the project is a stock Raspberry Pi model B with Raspbian.  It has an ethernet and a simple headphone jack for audio output.  The only other part required is an audio amplifier and speaker.


"""!speak <text> will speak the text"""

import re

import subprocess

def speak(m) :

    print 'speak("%s")' % m

    subprocess.call(['espeak', m])

    return 'Spoken!'

def on_message(msg, server):

    text = msg.get("text", "")

    match = re.findall(r"(!speak)\s*(.+)*", text)

    if not match: return

    msg = match[0][1]

    return speak(msg)

Launch Script:


cd /home/pi/slask-master

/usr/bin/python slask.py


check process speakbot

        matching "speakbot"

        start program = "/usr/bin/nohup /bin/sh /home/pi/slask-master/speakbot.sh > /tmp/speakbot.out &"

        stop program = "/usr/bin/killall slask"