-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
app.py
69 lines (56 loc) · 1.89 KB
/
app.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
"""
This is the main script of the application.
"""
import sys
import argparse
from dotenv import load_dotenv
from api.openai_functions.gpt_chat import chat_gpt
from api.microsoft_functions import graph_api
import api.microsoft_functions.ms_authserver as ms_authserver
import api.google_functions.google_api as google_api
from voice.elm327 import handle_voice_commands_elm327
from voice.voice_recognition import handle_common_voice_commands
from audio.audio_output import tts_output, initialize_audio
from config import EMAIL_PROVIDER
def main():
"""
Main function to encapsulate the script logic.
"""
load_dotenv()
email_provider = EMAIL_PROVIDER
initialize_audio()
response_text = chat_gpt("Hello")
print(response_text)
tts_output(response_text)
parser = argparse.ArgumentParser(description="Choose the device type")
parser.add_argument(
"--device",
choices=["none", "elm327"],
default="none",
help="Select the device type (default: none)",
)
args = parser.parse_args()
api_module = None
if email_provider == "365":
authorization_code = ms_authserver.get_auth_code()
graph_api.perform_graph_api_request(authorization_code)
api_module = graph_api
elif email_provider == "Google":
api_module = google_api
if args.device == "none":
if email_provider == "365":
handle_common_voice_commands(
args, api_module.user_object_id, email_provider
)
elif email_provider == "Google":
handle_common_voice_commands(
args, api_module.user_object_id, email_provider
)
elif args.device == "elm327":
handle_voice_commands_elm327(api_module.user_object_id)
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print("\nGoodbye for now ...\n")
sys.exit(0)