-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
336 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,324 @@ | ||
#Libraries needed for the program | ||
import pyttsx3 | ||
import speech_recognition as sr | ||
import webbrowser | ||
import datetime | ||
import wikipedia | ||
import os | ||
import sys | ||
import subprocess | ||
|
||
#What are the things while taking Query from user | ||
def takeCommand(): | ||
|
||
r = sr.Recognizer() | ||
|
||
with sr.Microphone() as source: | ||
print('Listening...') | ||
|
||
r.pause_threshold = 0.7 | ||
audio = r.listen(source) | ||
|
||
try: | ||
print("Recognizing...") | ||
|
||
Query = r.recognize_google(audio,language='en-in') | ||
print("You said=", Query) | ||
|
||
except Exception as e: | ||
print(e) | ||
speak("Sorry, I didn't understand. Can you rephrase it??") | ||
return "None" | ||
|
||
return Query | ||
|
||
#Voice Property of the program | ||
def speak(audio): | ||
engine = pyttsx3.init() | ||
|
||
voices = engine.getProperty('voices') | ||
|
||
engine.setProperty('voice', voices[0].id) | ||
|
||
print('Bagley:' + audio) | ||
engine.say(audio) | ||
engine.runAndWait() | ||
|
||
def tellDay(): | ||
day = datetime.datetime.today().weekday() + 1 | ||
|
||
Day_dict = {1: 'Monday', 2: 'Tuesday', | ||
3: 'Wednesday', 4: 'Thursday', 5: 'Friday', | ||
6: 'Saturday', | ||
7: 'Sunday'} | ||
if day in Day_dict.keys(): | ||
day_of_the_week = Day_dict[day] | ||
print(day_of_the_week) | ||
speak("The day is " + day_of_the_week) | ||
|
||
def tellTime(): | ||
|
||
time = str(datetime.datetime.now()) | ||
|
||
print(time) | ||
hour = time[11:13] | ||
min = time[14:16] | ||
speak("The time is" + hour + "Hours and" + min + "Minutes") | ||
|
||
#When Activated the program things to start with | ||
def Hello(): | ||
speak("System Booting up") | ||
|
||
speak("Connecting to Hrithvik Technologies Server's") | ||
|
||
speak("Success!") | ||
|
||
speak("Loading Bagley.py") | ||
|
||
speak("Loaded Successfully") | ||
|
||
speak("Connecting To The Internet") | ||
|
||
speak("Connection Established!") | ||
|
||
speak("I am Alive!") | ||
|
||
currentH = int(datetime.datetime.now().hour) | ||
if currentH >= 0 and currentH < 12: | ||
speak('Good Morning!') | ||
|
||
if currentH >= 12 and currentH < 18: | ||
speak('Good Afternoon!') | ||
|
||
if currentH >= 18 and currentH != 0: | ||
speak('Good Evening!') | ||
|
||
speak("How can i help you today?") | ||
|
||
def Take_query(): | ||
Hello() | ||
|
||
while(True): | ||
|
||
query = takeCommand().lower() | ||
|
||
# Websites opening commands | ||
|
||
if "open youtube" in query: | ||
speak("Opening Youtube") | ||
webbrowser.open("www.youtube.com") | ||
continue | ||
|
||
elif "open google" in query: | ||
speak("Opening Google") | ||
webbrowser.open("www.google.com") | ||
continue | ||
|
||
elif "open my youtube channel" in query: | ||
speak("Opening Your Youtube Channel") | ||
webbrowser.open("https://www.youtube.com/channel/UCj-YgHAXSK2R62hMOytdMew") | ||
continue | ||
|
||
elif "open my discord server" in query: | ||
speak("Opening Your discord server") | ||
webbrowser.open("https://discord.com/channels/832490246649151499/832490247098859563") | ||
continue | ||
|
||
elif "open classroom" in query: | ||
speak("Opening Google Classroom") | ||
webbrowser.open("https://classroom.google.com/u/1/h") | ||
continue | ||
|
||
elif "open google meet" in query: | ||
speak("Opening Google Meet") | ||
webbrowser.open("https://meet.google.com") | ||
continue | ||
|
||
elif "open speedtest" in query: | ||
speak("Opening speedtest") | ||
webbrowser.open("https://www.speedtest.net/") | ||
continue | ||
|
||
elif "open gmail" in query: | ||
speak("Opening Google Mail") | ||
webbrowser.open("https://mail.google.cin/mail/u/0/#inbox") | ||
continue | ||
|
||
elif "open github" in query: | ||
speak("Opening Github") | ||
webbrowser.open("https://github.com") | ||
continue | ||
|
||
elif "open netflix" in query: | ||
speak("Opening Netflix") | ||
webbrowser.open("https://netflix.com") | ||
continue | ||
|
||
elif "open prime video" in query: | ||
speak("Opening Prime Video") | ||
webbrowser.open("https://www.primevideo.com") | ||
continue | ||
|
||
elif "open studio" in query: | ||
speak("Opening Youtube Studio") | ||
webbrowser.open("https://studio.youtube.com/channel/UCj-YgHAXSK2R62hMOytdMew?c=UCj-YgHAXSK2R62hMOytdMew") | ||
continue | ||
|
||
elif "open drive" in query: | ||
speak("Opening Google Drive ") | ||
webbrowser.open("https://drive.google.com") | ||
continue | ||
|
||
elif "play linus tech tips" in query: | ||
speak("Playing Linus Tech Tips on youtube") | ||
webbrowser.open("https://www.youtube.com/watch?v=27DE26j5n8w&list=RDCMUCXuqSBlHAE6Xw-yeJA0Tunw") | ||
continue | ||
|
||
elif "open spotify developer" in query: | ||
speak("OPening Spotify Developers") | ||
webbrowser.open("https://developer.spotify.com/dashboard/applications") | ||
continue | ||
|
||
#Local application opening commands | ||
|
||
elif "open spotify" in query: | ||
speak("Opening Spotify") | ||
os.system("Spotify") | ||
continue | ||
|
||
elif "open virtualbox" in query: | ||
speak("Opening Virtual Box") | ||
subprocess.Popen("C:\Program Files\Oracle\VirtualBox\VirtualBox.exe") | ||
#os. system("Oracle VM VirtualBox") | ||
continue | ||
|
||
elif "open anydesk" in query: | ||
speak("Opening Anydesk") | ||
subprocess.Popen("C:\Program Files (x86)\AnyDesk\AnyDesk.exe") | ||
#os.system('C:\Program Files (x86)\AnyDesk\AnyDesk.exe') | ||
continue | ||
|
||
elif "illustrator" in query: | ||
speak("Opening Adobe Lightroom") | ||
subprocess.Popen("C:\Program Files\Adobe\Adobe Illustrator 2021\Support Files\Contents\Windows\Illustrator.exe") | ||
continue | ||
|
||
elif "open photoshop" in query: | ||
speak("Opeing Adobe Photoshop") | ||
subprocess.Popen("C:\Program Files\Adobe\Adobe Photoshop CC 2019\Photoshop.exe") | ||
continue | ||
|
||
elif "open premiere pro" in query: | ||
speak("Opening Adobe Premiere Pro") | ||
subprocess.Popen("C:\Program Files\Adobe\Adobe Premiere Pro 2021\Adobe Premiere Pro.exe") | ||
continue | ||
|
||
elif "open epic games" in query: | ||
speak("Opening Epic Games Launcher") | ||
subprocess.Popen("C:\Program Files (x86)\Epic Games\Launcher\Portal\Binaries\Win32\EpicGamesLauncher.exe") | ||
#os. system("C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Epic Games Launcher.lnk") | ||
continue | ||
|
||
elif "open pycharm" in query: | ||
speak("Opening PYCharm") | ||
subprocess.Popen('C:\\Program Files\\JetBrains\\PyCharm Community Edition 2021.1.1\\bin\\pycharm64.exe') | ||
# os. system("C:\Program Files\JetBrains\PyCharm Community Edition 2021.1.1\bin\pycharm64.exe") | ||
continue | ||
|
||
elif "open remote play" in query: | ||
speak("Opening PS Remote Play") | ||
subprocess.Popen('C:\Program Files (x86)\Sony\PS Remote Play\RemotePlay.exe') | ||
# os. system("C:\Program Files (x86)\Sony\PS Remote Play\RemotePlay.exe") | ||
continue | ||
|
||
elif "open fortnite" in query: | ||
speak("Opening Fortnite") | ||
subprocess.Popen("com.epicgames.launcher://apps/fn%3A4fe75bbc5a674f4f9b356b5c90567da5%3AFortnite?action=launch&silent=true") | ||
continue | ||
|
||
#Only Reply Commands | ||
|
||
elif "are you a human" in query: | ||
speak("Yes It's True I'm not a human, i am a digital assistant.") | ||
continue | ||
|
||
elif "i am alone" in query: | ||
speak("It's ok to be alone. If you need any kind of a help just tell me, i'm always there for you") | ||
continue | ||
|
||
elif "eat my poop" in query: | ||
speak("I was about to say the same thing to you!") | ||
continue | ||
|
||
elif "eat poop" in query: | ||
speak("I was about to say the same thing to you!") | ||
continue | ||
|
||
elif "introduce yourself to google" in query: | ||
speak("Hey Google, I am Bagley") | ||
continue | ||
|
||
elif "who made you" in query: | ||
speak("Technically i'm a character from Watch Dogs Legion, but i was brought to life by Mr. Hrithvik Bhardwaj. Thank you Mr. Hrithvik for bringing me to life.") | ||
continue | ||
|
||
elif "who are you" in query: | ||
speak("I am Bagley. Your Personalized Digital Assistant.") | ||
|
||
elif "what is the day" in query: | ||
tellDay() | ||
continue | ||
|
||
elif "who am i" in query: | ||
speak("You Are A Human") | ||
continue | ||
|
||
elif "what is the time" in query: | ||
tellTime() | ||
continue | ||
|
||
elif "how are you" in query: | ||
speak("I'm Good, Thanks for asking. How can i help you with??") | ||
continue | ||
|
||
elif "nothing" in query: | ||
speak("Oh, Ok") | ||
exit() | ||
|
||
elif "bye" in query: | ||
speak("Bye. see you later") | ||
exit() | ||
|
||
elif "thank you" in query: | ||
speak("My pleasure!") | ||
exit() | ||
|
||
elif "thanks" in query: | ||
speak("your Welcome") | ||
exit() | ||
|
||
elif "exit" in query: | ||
speak("Closing the Program Bagley.py") | ||
exit() | ||
|
||
elif "stop" in query: | ||
speak("ok") | ||
speak("See you later!") | ||
exit() | ||
|
||
elif "thanks bags" in query: | ||
speak("Your Welcome!") | ||
speak("by the way i'll be here if you need me. ") | ||
exit() | ||
|
||
elif "search wikipedia" in query: | ||
speak("Checking the wikipedia ") | ||
query = query.replace("wikipedia"," ") | ||
result = wikipedia.summary(query, sentences=20) | ||
speak(result) | ||
|
||
elif "introduce yourself" in query: | ||
speak("I am Bagley. Your Personalized Assistant") | ||
|
||
if __name__ == '__main__': | ||
Take_query() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# To start using the ai you need to have the following installed in your system | ||
1.Python3.9- I recommend using this version of python interpreter, as it work's smoothly with the ai | ||
|
||
2.Pyttsx3- this is a text to speech module for the python ai. you can download with this code using your command prompt or terminal `pip install pyttsx3` | ||
|
||
3.speechrecognition- this will understand the speech user says to the ai. To download type this in cmd or terminial `pip install SpeechRecognition` | ||
|
||
4.datetime- this will get the time for the ai to tell. to download type this in cmd or terminal `pip install datetime` | ||
|
||
5.wikipedia- this will help you get results from wikipedia directly. To download type this in cmd or terminal `pip install wikipedia` | ||
|
||
6.Pyaudio- PyAudio provides Python bindings for PortAudio, the cross-platform audio I/O library. With PyAudio, you can easily use Python to play and record audio. To download it you need to go to this link and download the version compatible with your python compiler. (https://www.lfd.uci.edu/~gohlke/pythonlibs/) |