-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathAssistant.py
More file actions
84 lines (72 loc) · 2.79 KB
/
Assistant.py
File metadata and controls
84 lines (72 loc) · 2.79 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
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
from gtts import gTTS
from playsound import playsound
import random
#===============================================INITIALIZATION==========================================================
initialization = "Initializing data"
language = 'en'
myobj = gTTS(text=initialization, lang=language, slow=False)
myobj.save("initialization.mp3")
playsound("initialization.mp3")
import datetime
#==============================================Asking the user for input================================================
askinit = gTTS(text="What should I do for you?", lang=language, slow=False)
askinit.save("askinit.mp3")
playsound("askinit.mp3")
#============================================Functions==================================================================
def time():
timern = datetime.datetime.now()
mytimern= gTTS(text="Please see the screen to see the time", lang=language, slow=False)
mytimern.save("mytimern.mp3")
playsound("mytimern.mp3")
print(timern)
def nofunc():
nofuncstr = gTTS(text="Sorry we don't provide this function right now", lang=language, slow=False)
nofuncstr.save("nofuncstr.mp3")
playsound("nofuncstr.mp3")
print("Sorry we don't provide this function right now")
def help():
helpstr=gTTS(text="List of available commands are Time help calculator nofunc", lang=language, slow=False)
helpstr.save("help.mp3")
playsound("help.mp3")
print("List of all commands\n"
"1)Help\n"
"2)Time\n"
"3)nofunc\n"
"4)calculator\n")
def calculator():
print("calculator")
def greet(yo):
name = raw_input("What's your name: ")
return yo + name
print greet("hi! ")
def speak(audio):
engine = pyttsx3.init()
# getter method(gets the current value
# of engine property)
voices = engine.getProperty('voices')
# setter method .[0]=male voice and
# [1]=female voice in set Property.
engine.setProperty('voice', voices[0].id)
# Method for the speaking of the assistant
engine.say(audio)
# Blocks while processing all the currently
# queued commands
engine.runAndWait()
#================================================Asking the user for input==============================================
while True:
r1 = random.randint(1, 10000000)
r2 = random.randint(1, 10000000)
task = input('What should I do for you?')
mytask = gTTS(text="Received Query "+task , lang=language , slow=False)
mytask.save(str(r1)+("task")+str(r2)+(".mp3"))
playsound(str(r1)+("task")+str(r2)+(".mp3"))
if task==("time"):
time()
elif task==("calculate"):
calculator()
elif task==("help"):
help()
elif task==("calculator"):
calculator()
else:
nofunc()