-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvisionproject.py
64 lines (54 loc) · 1.74 KB
/
visionproject.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
import pyttsx3
import speech_recognition as sr
import webbrowser
import datetime
import pyjokes
import os
import time
def sptext():
recognizer = sr.Recognizer()
with sr.Microphone() as source:
print("Listening...")
recognizer.adjust_for_ambient_noise(source)
audio = recognizer.listen(source)
try:
print("recognizing...")
data = recognizer.recognize_google(audio)
print(data)
return data
except sr.UnknownValueError:
print("Not Understand")
def speechtx(x):
engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)
engine.setProperty('rate', 100)
engine.say(x)
engine.runAndWait()
if __name__ == '__main__':
if "hello" in sptext().lower():
while True:
data1 = sptext().lower()
if "your name" in data1:
name = "my name is vision"
speechtx(name)
elif "old are you" in data1:
age = "i am few days old"
speechtx(age)
elif "time" in data1:
time = datetime.datetime.now().strftime("%I%M%p")
speechtx(time)
elif "youtube" in data1:
webbrowser.open("https://www.youtube.com/")
elif "gmail" in data1:
webbrowser.open("https://mail.google.com/mail/u/0/#inbox")
elif "joke" in data1:
joke_1 = pyjokes.get_joke(language="en", category="neutral")
print(joke_1)
speechtx(joke_1)
elif "exit" in data1:
speechtx("thank you")
break
time.sleep(3)
else:
print("thanks")