-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbless.py
64 lines (55 loc) · 2.32 KB
/
bless.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
from AI import Ai_assistent
from speech import Ai_assis
from mail import Mail
import json
log_data={}
def Bless_ai():
mail_password = 'your_mail_password'
mail_sender_email = '[email protected]'
api_key = 'your_openai_api_key'
azure_model_endpoint = 'your_azure_model_endpoint'
api_version = 'your_api_version'
speech_subscription = 'your_speech_subscription'
speech_model_region = 'your_speech_model_region'
AI=Ai_assistent(api_key=api_key,azure_model_endpoint=azure_model_endpoint,api_version=api_version)
MAIL=Mail(mail_password=mail_password,mail_sender_email=mail_sender_email)
user_and_ai=Ai_assis(subscription=speech_subscription,region=speech_model_region)
try:
text_output=user_and_ai.recognize_from_microphone()
language_detector=AI.Language_detect(text_output)
try:
mail_status=AI.Mail(text_output)
print(mail_status["status"])
print(mail_status)
except:
print("error")
mail_status={"status":"no"}
pass
if mail_status["status"] == "yes":
Ai_Listen_you=f"Sure your Email has been sent to {mail_status['details']['mail_id']}"
mail_id=mail_status['details']['mail_id']
subject=mail_status['details']['mail_title']
body=mail_status['details']['mail_desc']
MAIL.send_mail(mail_id,subject,body)
else:
Ai_Listen_you=AI.Assistent_listen(text_output)
pass
except:
text_output='error'
language_detector='en'
Ai_Listen_you="Sorry I can't hear you properly can you please say that again"
mail_status={"status":"no"}
finally:
log_data["user_text"]=text_output
log_data["user_language"]=language_detector
log_data["blessi_text"]=Ai_Listen_you
log_data["mail_status"]=mail_status["status"]
if mail_status["status"]=="yes": log_data["mail_data"]=mail_status
else: log_data["mail_data"]="None"
user_and_ai.text_to_speech(Ai_Listen_you,language_detector)
return log_data
#Some TEST
# AI=Ai_assistent()
# mail_status=AI.Mail("can u mail to my friend on [email protected] where u have ened to say that whazzup brob hows doing ")
# parsed_result = json.loads(mail_status)
# print(parsed_result['details']['mail_id'])