-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
67 lines (56 loc) · 2.39 KB
/
main.py
File metadata and controls
67 lines (56 loc) · 2.39 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from math import remainder
from click import command
from speech_recognition_engine import SpeechTextEngine
import config
from notion import NotionClient
from datetime import datetime
import time
notion_integration_token = config.NOTION_INTEGRATION_TOKEN
notion_database_id = config.NOTION_DATABASE_ID
sr = SpeechTextEngine()
notionClient = NotionClient(token=notion_integration_token,
database_id=notion_database_id)
if __name__ == "__main__":
remainder = 5
count = 0
while True:
count = 0
if sr.wakeup():
sr.speak("listening sir....")
time.sleep(0.5)
while True:
if count == remainder:
sr.speak("you didn't said anything for a while sir")
time.sleep(0.5)
command = sr.speech_recognition()
if "deactivate" in command: # for deactivate service temporarly
print("Deactivate!")
sr.speak("Deactivating")
break
if "note" in command or "todo" in command: # for createing notes
sr.speak("Tell me sir")
note = sr.speech_recognition()
if note == "":
sr.speak("you didn't said anything")
continue
else:
sr.speak('your todo is ' + note)
sr.speak(" should i store?")
command = sr.speech_recognition()
if "no" in command:
sr.speak("Ok sir")
continue
time_now = datetime.now().astimezone().isoformat()
status = "Active"
res = notionClient.create_page(desc=note,
date=time_now,
status=status)
if res.status_code == 200:
print("created successfully....!!!")
sr.speak("new note created")
else:
print(f"error :-> status code = {res.status_code}")
sr.speak("can't store the note")
if "exit" in command: # for exiting program
sr.speak("program terminating")
exit()