-
Notifications
You must be signed in to change notification settings - Fork 0
/
Marsh.py
97 lines (80 loc) · 2.93 KB
/
Marsh.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import eel
import sys
import os
import subprocess
from Brain.MarshBrain import ReplyBrain
from Body.Speak import Speak
from Body.Listen import MicExecution
from Main import MainTaskExecution
# Initialize Eel
eel.init('web')
os.system('start msedge.exe --start-maximized --app="http://localhost:8000/index.html"')
# Expose Python functions to JavaScript
@eel.expose
def start_assistant():
Speak("Hello Sir")
Speak("What can I do for you?")
while True:
data = MicExecution()
data = str(data)
value_return = MainTaskExecution(data)
if value_return:
pass
elif len(data) < 3:
pass
else:
reply = ReplyBrain(data)
Speak(reply)
@eel.expose
def exit_program():
Speak("Ok, I'll see you later")
sys.exit()
script_dir = os.path.dirname(os.path.realpath(__file__))
file_path = os.path.join(script_dir, 'Brain', 'Database', 'API.txt')
@eel.expose
def saveTextToFile(data):
script_dir = os.path.dirname(os.path.realpath(__file__))
file_path = os.path.join(script_dir, 'Brain', 'Database', 'API.txt')
with open(file_path, 'w') as file:
file.write(data)
@eel.expose
def openapi():
script_dir = os.path.dirname(os.path.realpath(__file__))
file_path = os.path.join(script_dir, 'Brain', 'Database', 'API.txt')
subprocess.Popen(['notepad.exe', file_path])
@eel.expose
def savecredToFile(email, password):
script_dir = os.path.dirname(os.path.realpath(__file__))
file_path = os.path.join(script_dir, 'Brain', 'Database', 'email_id_pass.txt')
formatted_cred = f"{email}\n{password}\n"
with open(file_path, 'w') as file:
file.write(formatted_cred)
@eel.expose
def opencred():
script_dir = os.path.dirname(os.path.realpath(__file__))
file_path = os.path.join(script_dir, 'Brain', 'Database', 'email_id_pass.txt')
subprocess.Popen(['notepad.exe', file_path])
@eel.expose
def saveemailToFile(data):
script_dir = os.path.dirname(os.path.realpath(__file__))
file_path = os.path.join(script_dir, 'Brain', 'Database', 'email_data.txt')
with open(file_path, 'a') as file:
file.write(data + '\n')
@eel.expose
def openemail():
script_dir = os.path.dirname(os.path.realpath(__file__))
file_path = os.path.join(script_dir, 'Brain', 'Database', 'email_data.txt')
subprocess.Popen(['notepad.exe', file_path])
@eel.expose
def savechatToFile(question, answer):
script_dir = os.path.dirname(os.path.realpath(__file__))
file_path = os.path.join(script_dir, 'Brain', 'Database', 'chat_log.txt')
formatted_log = f"You: {question}\nMarsh: {answer}\n"
with open(file_path, 'a') as file:
file.write(formatted_log)
@eel.expose
def openchat():
script_dir = os.path.dirname(os.path.realpath(__file__))
file_path = os.path.join(script_dir, 'Brain', 'Database', 'chat_log.txt')
subprocess.Popen(['notepad.exe', file_path])
eel.start('index.html',mode=None, host='localhost', block=True)