Merge branch 'main' into main

This commit is contained in:
Dasemu 2021-10-08 18:38:31 +02:00 committed by GitHub
commit 3333780e1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 57 additions and 44 deletions

View File

@ -7,8 +7,8 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- run: pip install --upgrade pip wheel
- run: pip install bandit black codespell flake8 flake8-bugbear
flake8-comprehensions isort mypy pytest pyupgrade safety
- run: pip install bandit black codespell flake8 flake8-bugbear flake8-comprehensions
flake8-return isort mypy pep8-naming pytest pyupgrade safety
- run: bandit --recursive --skip B311,B605 .
- run: black --check . || true
- run: codespell --ignore-words-list=ans

60
Jarvis2.py Normal file → Executable file
View File

@ -1,4 +1,7 @@
#!/usr/bin/env python3
import datetime
import getpass
import os
import random
import smtplib
@ -10,12 +13,12 @@ import speech_recognition as sr
import wikipedia
print("Initializing Jarvis....")
MASTER = "Harsha"
MASTER = getpass.getuser()
engine = pyttsx3.init("nsss")
voices = engine.getProperty("voices")
engine.setProperty("voice", voices[0].id)
popular_websites = {
"google": "https://www.google.com",
"youtube": "https://www.youtube.com",
@ -47,15 +50,17 @@ def speak(text):
engine.runAndWait()
def wishMe():
def print_and_speak(text):
print(text)
speak(text)
def wish_me():
hour = datetime.datetime.now().hour
# print(hour)
if hour >= 0 and hour < 12:
if hour < 12:
speak("Good Morning" + MASTER)
elif hour >= 12 and hour < 18:
elif hour < 18:
speak("Good Afternoon" + MASTER)
else:
speak("Good Evening" + MASTER)
@ -65,50 +70,53 @@ def wishMe():
# This is where our programme begins....
def takeCommand():
def take_command():
r = sr.Recognizer()
with sr.Microphone() as source:
print("Listening....")
r.pause_threshold = 0.5
audio = r.listen(source)
query = " "
print("Recognizing....")
query = ""
try:
print("Recognizing....")
query = r.recognize_google(audio, language="en-in")
print("user said: " + query)
print("User said: " + query)
except sr.UnknownValueError:
print("Sorry Could You please try again")
print("Sorry could you please try again?")
except Exception as e:
print(e)
print("Say That Again Please")
query = None
print("Say that again, please?")
return query
speak("Initializing Jarvis....")
wishMe()
query = takeCommand()
wish_me()
query = take_command().lower()
# logic for executing basic tasks
if "wikipedia" in query.lower():
speak("Searching wikipedia....")
query = query.replace("wikipedia", "")
results = wikipedia.summary(query, sentences=2)
print(results)
speak(results)
print_and_speak(wikipedia.summary(query, sentences=2))
elif "what's up" in query or "how are you" in query:
stMsgs = [
st_msgs = (
"Just doing my thing!",
"I am fine!",
"Nice!",
"I am nice and full of energy",
]
speak(random.choice(stMsgs))
)
speak(random.choice(st_msgs))
elif "date" in query:
print_and_speak(f"{datetime.datetime.now():%A, %B %d, %Y}")
elif "time" in query:
print_and_speak(f"{datetime.datetime.now():%I %M %p}")
elif "open" in query.lower():
website = query.replace("open", "").strip().lower()
@ -116,7 +124,7 @@ elif "open" in query.lower():
open_url(popular_websites[website])
except IndexError: # If the website is unknown
print(f"Unknown website: {website}")
speak(f"Sorry, i don't know the website {website}")
speak(f"Sorry, I don't know the website {website}")
elif "search" in query.lower():
search_query = query.split("for")[-1]
@ -125,12 +133,12 @@ elif "search" in query.lower():
elif "email" in query:
speak("Who is the recipient? ")
recipient = takeCommand()
recipient = take_command()
if "me" in recipient:
try:
speak("What should I say? ")
content = takeCommand()
content = take_command()
server = smtplib.SMTP("smtp.gmail.com", 587)
server.ehlo()

View File

@ -20,11 +20,12 @@ from commands import (
)
popular_websites = {
"google": "https://www.google.com",
"youtube": "https://www.youtube.com",
"wikipedia": "https://www.wikipedia.org",
"amazon": "https://www.amazon.com",
}
"google": "https://www.google.com",
"youtube": "https://www.youtube.com",
"wikipedia": "https://www.wikipedia.org",
"amazon": "https://www.amazon.com",
"GitHub": "https://www.github.com",
}
def main(search_engine, takeCommand, debug):
@ -125,3 +126,4 @@ else:
# if it doesn't exist it drops an error message and exits.
print('You need a config.ini file.')
print('Check the documentation in the Github Repository.')

View File

@ -1,10 +1,18 @@
# DesktopAssitant
# Desktop Assistant
A Virtual Desktop Assistant Written in Python.
<br> It's generally a basic virtual assistant
<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>
# Installing :
- Clone the repo to make it available on your local system by using ```git clone <FORKED_REPO_URL>```
- cd into the project directory i.e - ```cd DesktopAssitant```
- install requirements.txt ```pip install -r requirements.txt```
# Contributing Guidelines :<br>
- We are Open for Pull Requests
- Please contribute and add value to the code

View File

@ -1,10 +1,5 @@
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
wikipedia==1.4.0

8
run.md
View File

@ -42,7 +42,7 @@ pip install pyttsx3
- Open the command prompt/terminal and enter the below command to install `SpeechRecognition`
```md
pip install SpeechRecognition
pip install pyaudio SpeechRecognition
```
> Visit the [Speech Recognition documentation](https://pypi.org/project/SpeechRecognition/) to know more about this library.
@ -58,9 +58,9 @@ pip install pygame
# Suitable IDE for running this program
- Desktop Assistant can be run in the following Code editoe IDEs.
- Desktop Assistant can be run in the following code editor IDEs.
- [Pycharm](https://www.jetbrains.com/help/pycharm/installation-guide.html)
- [VS Code](https://code.visualstudio.com/docs)
- [Visual Studio Code](https://code.visualstudio.com/docs)
- [Jupyter-lab](https://jupyterlab.readthedocs.io/en/latest/)
- [Replit](https://docs.replit.com/)
@ -77,4 +77,4 @@ send email : Open email
: Abort
: Stop
End with : Bye
```
```