-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstop_listening.py
46 lines (37 loc) · 1.26 KB
/
stop_listening.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import time
import commands as cmd
import speak
def stopListening():
speak.speak('For how long?')
query = cmd.takeCommand()
if 'minutes' in query:
ans = int(query.replace('minutes', ''))
speak.speak(f'Going sleeping for {ans} minutes')
time.sleep(ans*60)
elif 'minute' in query:
ans = int(query.replace('minute', ''))
speak.speak(f'Going sleeping for {ans} minute')
time.sleep(ans*60)
elif 'hours' in query:
ans = int(query.replace('hours', ''))
speak.speak(f'Going sleeping for {ans} hours')
time.sleep(ans * 60 * 60)
elif 'hour' in query:
ans = int(query.replace('hour', ''))
speak.speak(f'Going sleeping for {ans} hour')
time.sleep(ans * 60 * 60)
elif 'seconds' in query:
ans = int(query.replace('seconds', ''))
speak.speak(f'Going sleeping for {ans} seconds')
time.sleep(ans)
elif 'second' in query:
ans = int(query.replace('second', ''))
speak.speak(f'Going sleeping for {ans} second')
time.sleep(ans)
else:
try:
ans = int(query)
speak.speak(f'Going sleeping for {ans} seconds')
time.sleep(ans)
except:
speak.speak('Can\'t get it')