I’m making a voice assistant and I want to teach him how to set a timer. I need to somehow implement a function that takes out the right amount of said time. I have an approximate working time of such a function, but it is not working
class TimerVoice():
def parse_command(text):
words = text.split()
if len(words) >= 5 and words[0] in ["put it on", "start it up"] and words[1] == and words[2] == "on":
try:
minutes = int(words[3])
word_minutes = words[4]
if word_minutes in ["minute", "minutes"]:
return minutes, word_minutesword_minutes
except ValueError:
pass
return None, None
def set_timer(minutes, word_minutes):
seconds = minutes * 60
time.sleep(seconds)
speaker(f"Time's up! Passed {minutes} {word_minutes}.")время
how do I take the number of minutes out of the said phrase and implement the timer function?
I expect that my assistant will be able to set the timer for the time specified to him