diff --git a/.github/workflows/lint_python.yml b/.github/workflows/lint_python.yml
index c3b9dc0..d850a6f 100644
--- a/.github/workflows/lint_python.yml
+++ b/.github/workflows/lint_python.yml
@@ -7,11 +7,11 @@ 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
+ - run: codespell --ignore-words-list=ans
- run: flake8 . --count --max-complexity=19 --max-line-length=88 --show-source --statistics
- run: isort --check-only --profile black .
- run: pip install -r requirements.txt || pip install --editable . || true
diff --git a/Jarvis2.py b/Jarvis2.py
old mode 100644
new mode 100755
index e2710c8..b37d890
--- a/Jarvis2.py
+++ b/Jarvis2.py
@@ -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()
diff --git a/Jarvis2_4windows.py b/Jarvis2_4windows.py
index ac9fe5f..f2a07cf 100644
--- a/Jarvis2_4windows.py
+++ b/Jarvis2_4windows.py
@@ -47,6 +47,7 @@ popular_websites = {
"youtube": "https://www.youtube.com",
"wikipedia": "https://www.wikipedia.org",
"amazon": "https://www.amazon.com",
+ "GitHub": "https://www.github.com",
}
search_engines = {
"google": "https://www.google.com",
@@ -74,7 +75,7 @@ def speak(text):
engine.runAndWait()
-def wishMe():
+def wish_me():
hour = datetime.datetime.now().hour
# print(hour)
if hour >= 0 and hour < 12:
@@ -90,14 +91,14 @@ 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 = " "
+ query = ""
try:
print("Recognizing....")
query = r.recognize_google(audio, language="en-in")
@@ -109,15 +110,14 @@ def takeCommand():
except Exception as e:
print(e)
print("Say That Again Please")
- query = None
return query
speak("Initializing Jarvis....")
-wishMe()
+wish_me()
while True:
- query = takeCommand()
+ query = take_command()
# logic for executing basic tasks
if "wikipedia" in query.lower():
@@ -128,13 +128,13 @@ while True:
speak(results)
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 "open" in query.lower():
website = query.replace("open", "").strip().lower()
@@ -151,12 +151,12 @@ while True:
elif "mail" 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()
diff --git a/README.md b/README.md
index 7735373..f3d309c 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,11 @@
-# DesktopAssitant
+# Desktop Assistant
A Virtual Desktop Assistant Written in Python.
It's generally a basic virtual assistant
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.
+
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
@@ -15,6 +16,15 @@ 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 ```
+- cd into the project directory i.e - ```cd DesktopAssitant```
+- install requirements.txt ```pip install -r requirements.txt```
+
+
+
+
# Contributing Guidelines :
- We are Open for Pull Requests
- Please contribute and add value to the code
diff --git a/requirements.txt b/requirements.txt
index 43d89b4..ce28810 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,4 +1,10 @@
pygame==2.0.1
pyttsx3==2.90
SpeechRecognition==3.8.1
-wikipedia==1.4.0
\ No newline at end of file
+wikipedia==1.4.0
+PyAudio==0.2.11
+pygame==2.0.1
+pyttsx3==2.90
+SpeechRecognition==3.8.1
+wikipedia==1.4.0
+
diff --git a/run.md b/run.md
new file mode 100644
index 0000000..8615c25
--- /dev/null
+++ b/run.md
@@ -0,0 +1,80 @@
+# How to run the program
+
+Here are some installation Guidelines and procedure how you can execute the programme and use it for performing basic tasks:
+
+## Table of Contents:
+
+- [Check for `PIP` installation](#check-for-pip-installation)
+- [Pyttsx3](#pyttsx3)
+- [Speech Recognition](#speech-recognition)
+- [Pygame
](#pygame-)
+- [Suitable IDE for running this program](#suitable-ide-for-running-this-program)
+- [Commands to interact with program.](#commands-to-interact-with-program)
+
+-------------------------------------
+## Check for `PIP` installation
+- PIP is a tool that is used to install python packages. PIP is automatically installed with Python 2.7. 9+ and Python 3.4+.
+- Open the command prompt and enter the below command to check whether pip is installed.
+```md
+pip --version
+```
+- If you are receiving an error, it means that you might be having `pip3` installed, so try this command.
+```md
+pip3 --version
+```
+```md
+python --version
+```
+> If you are still facing issues, try installing pip from [here](https://github.com/pypa/pip#readme)
+
+## Pyttsx3
+
+
+- pyttsx3 is a text-to-speech conversion library in Python. Unlike alternative libraries, it works offline, and is compatible with both Python 2 and 3
+- Open the command prompt/terminal and enter the below command to install `pyttsx3`
+```md
+pip install pyttsx3
+```
+> Visit the [Pyttsx3 documentation](https://pypi.org/project/pyttsx3/) to know more about this library.
+## Speech Recognition
+
+- SpeechRecognition is a library for performing speech recognition, with support for several engines and APIs, online and offline.
+- Open the command prompt/terminal and enter the below command to install `SpeechRecognition`
+
+```md
+pip install pyaudio SpeechRecognition
+```
+> Visit the [Speech Recognition documentation](https://pypi.org/project/SpeechRecognition/) to know more about this library.
+
+
+## Pygame
+
+- Pygame is a set of Python modules designed for writing video games. Pygame adds functionality on top of the excellent SDL library. This allows you to create fully featured games and multimedia programs in the python language.
+- Open the command prompt/terminal and enter the below command to install `Pygame`
+
+```md
+pip install pygame
+```
+
+# Suitable IDE for running this program
+
+- Desktop Assistant can be run in the following code editor IDEs.
+ - [Pycharm](https://www.jetbrains.com/help/pycharm/installation-guide.html)
+ - [Visual Studio Code](https://code.visualstudio.com/docs)
+ - [Jupyter-lab](https://jupyterlab.readthedocs.io/en/latest/)
+ - [Replit](https://docs.replit.com/)
+
+# Commands to interact with program.
+
+After successful installation of the forementioned dependencies, you can use the following commands (speak out) to interact with Jarvis, your `Desktop-Assistant`
+```
+Start with : Hello
+Random Ans : How are you?
+ : Google
+ : Youtube
+send email : Open email
+ : Nothing
+ : Abort
+ : Stop
+End with : Bye
+```