forked from preeteshchauhan/Float-The-Voice-Assistance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalculatenumbers.py
40 lines (33 loc) · 956 Bytes
/
Calculatenumbers.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
import wolframalpha
import pyttsx3
import speech_recognition
engine = pyttsx3.init("sapi5")
voices = engine.getProperty("voices")
engine.setProperty("voice", voices[0].id)
rate = engine.setProperty("rate",170)
def speak(audio):
engine.say(audio)
engine.runAndWait()
def WolfRamAlpha(query):
apikey = "X6Q389-H5JQW7AA47"
requester = wolframalpha.Client(apikey)
requested = requester.query(query)
try:
answer = next(requested.results).text
return answer
except:
speak("The value is not answerable")
def Calc(query):
Term = str(query)
Term = Term.replace("jarvis","")
Term = Term.replace("multiply","*")
Term = Term.replace("plus","+")
Term = Term.replace("minus","-")
Term = Term.replace("divide","/")
Final = str(Term)
try:
result = WolfRamAlpha(Final)
print(f"{result}")
speak(result)
except:
speak("The value is not answerable")