-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathJarvis.txt
More file actions
47 lines (45 loc) · 1.21 KB
/
Jarvis.txt
File metadata and controls
47 lines (45 loc) · 1.21 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 datetime
import pyaudio
import wikipedia
import speech_recognition as sr
import random
engine=pyttsx3.init('sapi5')
voices=engine.getProperty('voices')
print(voices[0].id)
engine.setProperty('voice',voices[0].id)
def speak(audio):
engine.say(audio)
engine.runAndWait()
def wiki(a):
result=wikipedia.summary(a,sentences=2)
speak(result)
def wishme():
hour = int(datetime.datetime.now().hour)
if hour>=0 and hour<12:
speak('good morniong sir')
elif hour>=12 and hour<18:
speak('good after noon')
else:
speak('good eveing')
speak('I am jarvis sir please tell me how may i help you')
def takecommand():
r=sr.Recognizer()
with sr.Microphone() as source:
print('listening...')
r.pause_threshold=1
audio=r.listen(source)
try:
print('recognising...')
query=r.recognize_google(audio,language='en-in')
print('user said',query)
except Exception as e:
speak('say again please')
print('say again...')
return "None"
return query
wishme()
while True:
query = takecommand().lower()
if 'wikipedia' in query:
wiki(query)