-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCal.py
More file actions
47 lines (36 loc) · 1.08 KB
/
Cal.py
File metadata and controls
47 lines (36 loc) · 1.08 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
import pyttsx3
import speech_recognition
import wolframalpha
Assistant =pyttsx3.init('sapi5')
voices = Assistant.getProperty('voices')
print(voices)
Assistant.setProperty('voices',voices[0].id)
Assistant.setProperty('rate', 200 )
def Speak(audio):
print(" ")
Assistant.say(audio)
print(f": {audio}")
Assistant.runAndWait()
def Wolfram(query):
api_key = "LR33QE-LUP5Q99YK4"
requester = wolframalpha.Client(api_key)
requested = requester.query(query)
try:
Answer = next(requested.results).text
return Answer
except:
Speak("Sorry sir but the value is not answerable!")
def calc(query):
Term = str(query)
Term = Term.replace("ERA"," ")
Term = Term.replace("plus","+")
Term = Term.replace("minus","-")
Term = Term.replace("divide","/")
Term = Term.replace("multiply","*")
Final = str(Term)
try:
result = Wolfram(Final)
print(f"{result}")
Speak(result)
except:
Speak("Sorry sir the query is not ansewerable!")