-
Notifications
You must be signed in to change notification settings - Fork 1
/
ApolloAi.py
92 lines (76 loc) · 2.47 KB
/
ApolloAi.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import imp
import webbrowser
import pyttsx3
import speech_recognition as sr
import datetime
import wikipedia
import os
import smtplib
import time
# define speaking
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[0].id)
def speak(text):
engine.say(text)
engine.runAndWait()
def initial():
# Initialization...
speak("Initializing Apollo..")
print("Initializing Apollo..")
speak("30%..")
print("30%..")
speak("45%..")
print("45%..")
speak("74%..")
print("74%..")
speak("100%\n Welcome To Apollo Ai")
print("100%\n Welcome To Apollo Ai")
def Command():
r = sr.Recognizer()
with sr.Microphone() as source:
print('Im Listening...')
speak('What would you like me to do?')
audio = r.listen(source)
try :
print('Recognizing...')
speak('Recognizing...')
query = r.recognize_google(audio, language='en-us')
print(f' User said: {query}\n')
speak(f' User said: {query}')
except Exception as e:
print('Please repeat that.')
speak('Please repeat that.')
query = None
return query
# initial()
query = Command()
if 'wikipedia' in query.lower():
print("Searching wikipedia...")
speak("Searching wikipedia...")
query = query.replace("wikipedia", '')
results = wikipedia.summary(query, sentences= 2)
print(f'\n {results} \n')
speak(results)
elif 'open youtube' in query.lower():
webbrowser.open('https://youtube.com')
speak('Youtube is now open')
print('Youtube is now open.')
elif 'open google' in query.lower():
webbrowser.open('https://google.com')
speak('Google is now open')
print('Google is now open.')
elif 'play lo-fi' in query.lower():
webbrowser.open('https://www.youtube.com/watch?v=mStI2VsCGhM&list=PLdUzWlLG9V3MAuZsEDROwPBLzDw1pC-RR')
speak('playing lofi')
print('playing lofi')
elif 'play lofi' in query.lower():
webbrowser.open('https://www.youtube.com/watch?v=mStI2VsCGhM&list=PLdUzWlLG9V3MAuZsEDROwPBLzDw1pC-RR')
speak('playing lofi')
print('playing lofi')
elif 'time' in query.lower():
strTime = datetime.datetime.now().strftime('%H:%M:%S')
speak(f"The time is {strTime}")
elif 'open discord' in query.lower():
Path1 = 'C:\\Users\\bobsf\\AppData\\Local\\DiscordPTB\\app-1.0.1010\\DiscordPTB.exe'
os.startfile(Path1)