Merge branch 'main' of https://github.com/Harsha200105/DesktopAssistant into Harsha200105-main
This commit is contained in:
commit
9afa57dec5
@ -3,7 +3,14 @@ import os
|
|||||||
|
|
||||||
import speech_recognition as sr
|
import speech_recognition as sr
|
||||||
|
|
||||||
from actions import search_engine_selector, speak, wish_me
|
from actions import (
|
||||||
|
change_volume,
|
||||||
|
change_rate,
|
||||||
|
change_voice,
|
||||||
|
search_engine_selector,
|
||||||
|
speak,
|
||||||
|
wish_me,
|
||||||
|
)
|
||||||
from commands import (
|
from commands import (
|
||||||
command_bye,
|
command_bye,
|
||||||
command_hello,
|
command_hello,
|
||||||
@ -30,45 +37,57 @@ popular_websites = {
|
|||||||
|
|
||||||
def main(search_engine, take_command, debug):
|
def main(search_engine, take_command, debug):
|
||||||
while True:
|
while True:
|
||||||
query = take_command().lower()
|
try:
|
||||||
|
query = take_command()
|
||||||
|
|
||||||
# logic for executing commands without arguments
|
# logic for executing commands without arguments
|
||||||
phrases = {
|
phrases = {
|
||||||
"what's up": command_whatsup,
|
"what's up": command_whatsup,
|
||||||
"nothing": command_nothing,
|
"nothing": command_nothing,
|
||||||
"abort": command_nothing,
|
"abort": command_nothing,
|
||||||
"stop": command_nothing,
|
"stop": command_nothing,
|
||||||
"hello": command_hello,
|
"hello": command_hello,
|
||||||
"bye": command_bye,
|
"bye": command_bye,
|
||||||
"play music": command_play_music,
|
"play music": command_play_music,
|
||||||
"unpause": command_unpause_music,
|
"unpause": command_unpause_music,
|
||||||
"pause music": command_pause_music,
|
"pause music": command_pause_music,
|
||||||
"stop music": command_stop_music,
|
"stop music": command_stop_music
|
||||||
}
|
}
|
||||||
for phrase, command in phrases.items():
|
for phrase, command in phrases.items():
|
||||||
if phrase in query:
|
if phrase in query:
|
||||||
command()
|
command()
|
||||||
|
|
||||||
# logic for executing commands with arguments
|
# logic for executing commands with arguments
|
||||||
if "wikipedia" in query.lower():
|
if "wikipedia" in query:
|
||||||
command_wikipedia(speak, debug, query)
|
command_wikipedia(speak, debug, query)
|
||||||
|
|
||||||
elif "open" in query.lower():
|
elif "open" in query:
|
||||||
command_open(
|
command_open(
|
||||||
query,
|
query,
|
||||||
popular_websites,
|
popular_websites,
|
||||||
debug,
|
debug,
|
||||||
search_engine,
|
search_engine,
|
||||||
take_command
|
take_command
|
||||||
)
|
)
|
||||||
|
|
||||||
elif "search" in query.lower():
|
elif "search" in query:
|
||||||
command_search(query, search_engine)
|
command_search(query, search_engine)
|
||||||
|
|
||||||
elif "mail" in query:
|
elif "mail" in query:
|
||||||
command_mail(take_command)
|
command_mail(take_command)
|
||||||
|
|
||||||
speak("Next Command! Sir!")
|
elif "change rate" in query:
|
||||||
|
change_rate(query, take_command)
|
||||||
|
|
||||||
|
elif "change voice" in query.lower():
|
||||||
|
change_voice(query, take_command)
|
||||||
|
|
||||||
|
elif "change volume" in query.lower():
|
||||||
|
change_volume(query, take_command)
|
||||||
|
|
||||||
|
speak("Next Command! Sir!")
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
@ -109,7 +128,7 @@ def run():
|
|||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return
|
return query
|
||||||
|
|
||||||
speak(text="Initializing Jarvis....")
|
speak(text="Initializing Jarvis....")
|
||||||
wish_me(master)
|
wish_me(master)
|
||||||
|
|||||||
12
README.md
12
README.md
@ -5,6 +5,17 @@ A Virtual Desktop Assistant Written in Python.
|
|||||||
<img src="https://github.com/Harsha200105/DesktopAssitant/blob/main/resource/JJ.jpeg"> <br>
|
<img src="https://github.com/Harsha200105/DesktopAssitant/blob/main/resource/JJ.jpeg"> <br>
|
||||||
The basic purpose of this is to make work easier as it re-directs you to various main sites and performs various important functions for your PC as well just install it for your system and run it in your code editor or IDE. I will be soon updating it as an application for MacOS, Linux and Windows. Until then you can follow the Contributing Guidelines and Contribute into this Desktop Assistant.<br>
|
The basic purpose of this is to make work easier as it re-directs you to various main sites and performs various important functions for your PC as well just install it for your system and run it in your code editor or IDE. I will be soon updating it as an application for MacOS, Linux and Windows. Until then you can follow the Contributing Guidelines and Contribute into this Desktop Assistant.<br>
|
||||||
|
|
||||||
|
|
||||||
|
Steps to run the Assistant on your pc------------------(use python 3.9)
|
||||||
|
|
||||||
|
Step1. Installing all the necessary python module as mentioned in the requirements.txt file one by one as from the terminal pip install <module_name==version>
|
||||||
|
or
|
||||||
|
Install all the required module all at once by using the command pip install -r requirements.txt
|
||||||
|
|
||||||
|
Step2. For windows user run Jarvis2_4windows.py script.
|
||||||
|
|
||||||
|
Wow All done! Now give the command to jarvis.
|
||||||
|
|
||||||
# Installing :
|
# Installing :
|
||||||
|
|
||||||
- Clone the repo to make it available on your local system by using ```git clone <FORKED_REPO_URL>```
|
- Clone the repo to make it available on your local system by using ```git clone <FORKED_REPO_URL>```
|
||||||
@ -13,6 +24,7 @@ The basic purpose of this is to make work easier as it re-directs you to various
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Contributing Guidelines :<br>
|
# Contributing Guidelines :<br>
|
||||||
- We are Open for Pull Requests
|
- We are Open for Pull Requests
|
||||||
- Please contribute and add value to the code
|
- Please contribute and add value to the code
|
||||||
|
|||||||
BIN
__pycache__/Jarvis2.cpython-37.pyc
Normal file
BIN
__pycache__/Jarvis2.cpython-37.pyc
Normal file
Binary file not shown.
Binary file not shown.
90
actions.py
90
actions.py
@ -3,10 +3,7 @@ import webbrowser
|
|||||||
|
|
||||||
import pyttsx3
|
import pyttsx3
|
||||||
import requests
|
import requests
|
||||||
|
import configparser
|
||||||
engine = pyttsx3.init("sapi5")
|
|
||||||
voices = engine.getProperty("voices")
|
|
||||||
engine.setProperty("voice", voices[0].id)
|
|
||||||
|
|
||||||
|
|
||||||
def search_engine_selector(config):
|
def search_engine_selector(config):
|
||||||
@ -19,7 +16,9 @@ def search_engine_selector(config):
|
|||||||
elif config['DEFAULT']['search_engine'] == 'Youtube':
|
elif config['DEFAULT']['search_engine'] == 'Youtube':
|
||||||
return "https://www.youtube.com"
|
return "https://www.youtube.com"
|
||||||
else:
|
else:
|
||||||
# If none of default ones selected
|
# If none of default ones selected triesto fetch https://example.com
|
||||||
|
# to see if its valid as search engine and if its valid it uses it.
|
||||||
|
# If not valid it uses Google.
|
||||||
try:
|
try:
|
||||||
if requests.get(
|
if requests.get(
|
||||||
f"https://{config['DEFAULT']['search_engine'].lower()}.com",
|
f"https://{config['DEFAULT']['search_engine'].lower()}.com",
|
||||||
@ -63,3 +62,84 @@ def wish_me(master):
|
|||||||
speak("Good Evening" + master)
|
speak("Good Evening" + master)
|
||||||
|
|
||||||
# speak("Hey I am Jarvis. How may I help you")
|
# speak("Hey I am Jarvis. How may I help you")
|
||||||
|
|
||||||
|
|
||||||
|
def change_rate(query, take_command):
|
||||||
|
try:
|
||||||
|
rate = query.split('to')[-1]
|
||||||
|
engine.setProperty('rate', int(rate))
|
||||||
|
speak("¿Do you want to keep this config?")
|
||||||
|
answer = take_command()
|
||||||
|
if answer == "yes":
|
||||||
|
config['DEFAULT']['rate'] = rate
|
||||||
|
with open('config.ini', 'w') as configfile:
|
||||||
|
config.write(configfile)
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
except Exception:
|
||||||
|
speak("Invalid value. Please try again.")
|
||||||
|
|
||||||
|
|
||||||
|
def change_voice(query, take_command):
|
||||||
|
try:
|
||||||
|
voice = query.split('to')[-1]
|
||||||
|
if voice == "male":
|
||||||
|
engine.setProperty('voice', voices[0].id)
|
||||||
|
speak("¿Do you want to keep this config?")
|
||||||
|
if take_command() == "yes":
|
||||||
|
config['DEFAULT']['voice'] = 'Male'
|
||||||
|
with open('config.ini', 'w') as configfile:
|
||||||
|
config.write(configfile)
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif voice == "female":
|
||||||
|
engine.setProperty('voice', voices[1].id)
|
||||||
|
speak("¿Do you want to keep this config?")
|
||||||
|
answer = take_command()
|
||||||
|
print(answer)
|
||||||
|
if answer == "yes":
|
||||||
|
config['DEFAULT']['voice'] = 'Female'
|
||||||
|
with open('config.ini', 'w') as configfile:
|
||||||
|
config.write(configfile)
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
speak("Invalid value. Please try again.")
|
||||||
|
except Exception:
|
||||||
|
speak("Invalid value. Please try again.")
|
||||||
|
|
||||||
|
|
||||||
|
def change_volume(query, take_command):
|
||||||
|
try:
|
||||||
|
volume = query.split('to')[-1]
|
||||||
|
engine.setProperty('volume', int(volume)/100)
|
||||||
|
speak("¿Do you want to keep this config?")
|
||||||
|
answer = take_command()
|
||||||
|
if answer == "yes":
|
||||||
|
config['DEFAULT']['volume'] = volume
|
||||||
|
with open('config.ini', 'w') as configfile:
|
||||||
|
config.write(configfile)
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
except Exception:
|
||||||
|
speak("Invalid value. Please try again.")
|
||||||
|
|
||||||
|
|
||||||
|
engine = pyttsx3.init("sapi5")
|
||||||
|
voices = engine.getProperty("voices")
|
||||||
|
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
config.read('config.ini')
|
||||||
|
|
||||||
|
if config['DEFAULT']['voice'] == 'Male':
|
||||||
|
engine.setProperty('voice', voices[0].id)
|
||||||
|
else:
|
||||||
|
engine.setProperty('voice', voices[1].id)
|
||||||
|
|
||||||
|
try:
|
||||||
|
engine.setProperty('rate', int(config['DEFAULT']['rate']))
|
||||||
|
engine.setProperty('volume', int(config['DEFAULT']['volume'])/100)
|
||||||
|
|
||||||
|
except Exception:
|
||||||
|
speak("Bad config. Setting up default values")
|
||||||
|
|||||||
13
config.ini
13
config.ini
@ -1,14 +1,15 @@
|
|||||||
[DEFAULT]
|
[DEFAULT]
|
||||||
master = YourName
|
master = YourName
|
||||||
search_engine = Google
|
search_engine = Google
|
||||||
#Google/Bing/DuckDuckGo/Youtube
|
debug = False
|
||||||
debug = True
|
musicpath =
|
||||||
#True/False
|
voice = Male
|
||||||
musicPath =
|
rate = 150
|
||||||
|
volume = 100
|
||||||
|
|
||||||
[EMAIL]
|
[EMAIL]
|
||||||
server = smtp.gmail.com
|
server = smtp.gmail.com
|
||||||
#You can use any email service provider that allows SMTP. Check docs to see how to configure your email provider here.
|
|
||||||
port = 587
|
port = 587
|
||||||
#In most cases you will need this port.
|
|
||||||
username =
|
username =
|
||||||
password =
|
password =
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,10 @@
|
|||||||
|
pygame==2.0.1
|
||||||
|
pyttsx3==2.90
|
||||||
|
SpeechRecognition==3.8.1
|
||||||
|
wikipedia==1.4.0
|
||||||
PyAudio==0.2.11
|
PyAudio==0.2.11
|
||||||
pygame==2.0.1
|
pygame==2.0.1
|
||||||
pyttsx3==2.90
|
pyttsx3==2.90
|
||||||
SpeechRecognition==3.8.1
|
SpeechRecognition==3.8.1
|
||||||
wikipedia==1.4.0
|
wikipedia==1.4.0
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user