-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasics.py
More file actions
83 lines (82 loc) · 2.2 KB
/
Basics.py
File metadata and controls
83 lines (82 loc) · 2.2 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
import pyttsx3
import datetime
import playsound
from datetime import date
import speech_recognition as sr
import subprocess
import webbrowser
from pydictionary import Dictionary as dictionary
#spech
def speak(text):
engine = pyttsx3.init()
engine.say(text)
engine.runAndWait()
#audio
def audio():
r = sr.Recognizer()
with sr.Microphone() as source:
audio = r.listen(source)
said = r.recognize_google(audio)
print(said)
return said.lower()
#greeting
def wishme():
t=int(datetime.datetime.now().hour)
if t>=0 and t<12:
speak("Good Morning")
elif t>=12 and t<16:
speak("Good Afternoon")
else:
speak("Good Evening")
#date_time
def date_time():
today = date.today()
t=(datetime.datetime.now())
speak("Today's date:", today,"Time is",t)
#note making
def take_note(text):
date=datetime.datetime.now()
file_name=str((date).replace(":", "-") + "-note.exe")
with open(file_name, "w") as f:
f.write(text)
subprocess.Popen(["notepad.exe", file_name])
#speak("Hello")
#wishme()
#audio()
def main(x):
if "take note" in x:
speak("what would you like me to note")
text=audio()
take_note(text)
elif "youtube" in x:
webbrowser.open("youtube.com")
elif "google" in x:
webbrowser.open("google.com")
elif "search" in x:
speak("what do you want me to search")
query=audio()
elif "open" in x:
speak("which app")
app=audio()
open(app)
elif "meaning" in x:
speak("please say the word to find meaning of")
word=audio()
speak(dictionary.meaning(word))
elif "synonyms" in x:
speak("please say the word")
wo=audio()
speak(dictionary.synonym(wo))
elif "antonyms" in x:
speak("please say the word")
an=audio()
speak(dictionary.antonym(an))
elif "translate" in x:
speak("please say the word")
word=audio()
speak("language to be translated in")
lang=audio()
speak(dictionary.translate(word,lang))
wishme()
x=audio()
main(x)