Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
class setTimer(object):
def __init__(self, say, keyword):
self.say = say
self.keyword = keyword
def to_number(self, number_string):
number = {'one':1,
return number[number_string]
def run(self, voice_command):
command = voice_command.replace(self.keyword, '', 1)"received timer set command " + command )
length, unit = command.split(' ')
length = float(length)
except (ValueError):
length = float(self.to_number(length))
if (unit == "minutes") or (unit == "minute"):
length = length * 60"setting a timer for " + str(length) )
self.say("setting a timer for " + str(length) + " seconds")
t = threading.Timer(length, self.say, ["Time is up"]).start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.