Merge pull request #3 from TallGorilla/Harsha200105-main

Harsha200105 main
This commit is contained in:
Dasemu 2021-10-09 12:43:52 +02:00 committed by GitHub
commit 6b701ce3c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 164 additions and 47 deletions

View File

@ -3,7 +3,14 @@ import os
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 (
command_bye,
command_hello,
@ -30,7 +37,8 @@ popular_websites = {
def main(search_engine, take_command, debug):
while True:
query = take_command().lower()
try:
query = take_command()
# logic for executing commands without arguments
phrases = {
@ -43,17 +51,17 @@ def main(search_engine, take_command, debug):
"play music": command_play_music,
"unpause": command_unpause_music,
"pause music": command_pause_music,
"stop music": command_stop_music,
"stop music": command_stop_music
}
for phrase, command in phrases.items():
if phrase in query:
command()
# logic for executing commands with arguments
if "wikipedia" in query.lower():
if "wikipedia" in query:
command_wikipedia(speak, debug, query)
elif "open" in query.lower():
elif "open" in query:
command_open(
query,
popular_websites,
@ -62,13 +70,24 @@ def main(search_engine, take_command, debug):
take_command
)
elif "search" in query.lower():
elif "search" in query:
command_search(query, search_engine)
elif "mail" in query:
command_mail(take_command)
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():
@ -109,7 +128,7 @@ def run():
else:
pass
return
return query
speak(text="Initializing Jarvis....")
wish_me(master)

View File

@ -5,6 +5,17 @@ A Virtual Desktop Assistant Written in Python.
<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>
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 :
- 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>
- We are Open for Pull Requests
- Please contribute and add value to the code

Binary file not shown.

Binary file not shown.

View File

@ -3,10 +3,7 @@ import webbrowser
import pyttsx3
import requests
engine = pyttsx3.init("sapi5")
voices = engine.getProperty("voices")
engine.setProperty("voice", voices[0].id)
import configparser
def search_engine_selector(config):
@ -19,7 +16,9 @@ def search_engine_selector(config):
elif config['DEFAULT']['search_engine'] == 'Youtube':
return "https://www.youtube.com"
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:
if requests.get(
f"https://{config['DEFAULT']['search_engine'].lower()}.com",
@ -63,3 +62,84 @@ def wish_me(master):
speak("Good Evening" + master)
# 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")

View File

@ -1,14 +1,15 @@
[DEFAULT]
master = YourName
search_engine = Google
#Google/Bing/DuckDuckGo/Youtube
debug = True
#True/False
musicPath =
debug = False
musicpath =
voice = Male
rate = 150
volume = 100
[EMAIL]
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
#In most cases you will need this port.
username =
password =

View File

@ -1,5 +1,10 @@
pygame==2.0.1
pyttsx3==2.90
SpeechRecognition==3.8.1
wikipedia==1.4.0
PyAudio==0.2.11
pygame==2.0.1
pyttsx3==2.90
SpeechRecognition==3.8.1
wikipedia==1.4.0