From 4ed09c38e71fdbe311ceddd56687c5d61eeee3aa Mon Sep 17 00:00:00 2001 From: yangman946 Date: Wed, 6 Oct 2021 10:58:55 +1100 Subject: [PATCH 01/10] added requirements --- README.md | 8 ++++++++ requirements.txt | 4 ++++ 2 files changed, 12 insertions(+) create mode 100644 requirements.txt diff --git a/README.md b/README.md index 79f71c2..cc71e39 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,14 @@ A Virtual Desktop Assistant Written in Python.
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.
+# 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 new file mode 100644 index 0000000..c1df40c --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +wikipedia==1.4.0 +pyttsx3==2.90 +SpeechRecognition==3.8.1 +pygame==2.0.1 From b1bda0768269aa671ebe8bdc5e4d53aab36c593f Mon Sep 17 00:00:00 2001 From: Clarence Yang Date: Wed, 6 Oct 2021 18:25:28 +1100 Subject: [PATCH 02/10] Update requirements.txt --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index c1df40c..780fd30 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -wikipedia==1.4.0 +pygame==2.0.1 pyttsx3==2.90 SpeechRecognition==3.8.1 -pygame==2.0.1 +wikipedia==1.4.0 From 14e323fd1be4f5b89497926761c8759104f807bb Mon Sep 17 00:00:00 2001 From: JOS-RE Date: Thu, 7 Oct 2021 02:09:01 +0530 Subject: [PATCH 03/10] Added run.md : Gives instructions on how to run the program --- run.md | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 run.md diff --git a/run.md b/run.md new file mode 100644 index 0000000..59dcaea --- /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 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 editoe IDEs. + - [Pycharm](https://www.jetbrains.com/help/pycharm/installation-guide.html) + - [VS 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 +``` \ No newline at end of file From 7058d20a44b8672d5919d14c89c542f09f216588 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 6 Oct 2021 23:06:24 +0200 Subject: [PATCH 04/10] codespell --ignore-words-list=ans --- .github/workflows/lint_python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint_python.yml b/.github/workflows/lint_python.yml index c3b9dc0..335a50d 100644 --- a/.github/workflows/lint_python.yml +++ b/.github/workflows/lint_python.yml @@ -11,7 +11,7 @@ jobs: flake8-comprehensions isort mypy 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 From 1ce8e01f365a89c7cfef19ec3af0e5df31c11c89 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 7 Oct 2021 00:18:58 +0200 Subject: [PATCH 05/10] =?UTF-8?q?Need=20pyaudio=20for=20SpeechRecognition?= =?UTF-8?q?=20to=20receive=20=F0=9F=8E=A4=20input?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://pypi.org/project/SpeechRecognition/ --- run.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run.md b/run.md index 59dcaea..9f8bd28 100644 --- a/run.md +++ b/run.md @@ -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. @@ -77,4 +77,4 @@ send email : Open email : Abort : Stop End with : Bye -``` \ No newline at end of file +``` From 1e01516dabf759fcffa0c9a57829458079db7f9a Mon Sep 17 00:00:00 2001 From: Clarence Yang Date: Thu, 7 Oct 2021 09:42:00 +1100 Subject: [PATCH 06/10] Update requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 780fd30..83f9283 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ +PyAudio==0.2.11 pygame==2.0.1 pyttsx3==2.90 SpeechRecognition==3.8.1 From e8e441abcff8e544995c2ab56849b6b73c0baf08 Mon Sep 17 00:00:00 2001 From: BEiNg139 <92037990+BEiNg139@users.noreply.github.com> Date: Wed, 6 Oct 2021 18:50:55 -0400 Subject: [PATCH 07/10] Add github to popular websites I am a novice coder and I am trying to help just adding things. Sorry to bother you. --- Jarvis2_4windows.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Jarvis2_4windows.py b/Jarvis2_4windows.py index bb9aa14..ef5c3d5 100644 --- a/Jarvis2_4windows.py +++ b/Jarvis2_4windows.py @@ -22,6 +22,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", From 4f78ebd2765b728c4b5dea4f75abc0af3ce86f9f Mon Sep 17 00:00:00 2001 From: yangman946 Date: Thu, 7 Oct 2021 19:07:05 +1100 Subject: [PATCH 08/10] fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cc71e39..2101d9c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# DesktopAssitant +# Desktop Assistant A Virtual Desktop Assistant Written in Python.
It's generally a basic virtual assistant From e1f03a4b9007497b0474d624c0edd63447eb62f3 Mon Sep 17 00:00:00 2001 From: Jeremy Zimmerman Date: Thu, 7 Oct 2021 08:05:01 -0700 Subject: [PATCH 09/10] Spelling and small rewording Spelling of editor and fully spelling out abbreviation of VS Code --- run.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/run.md b/run.md index 59dcaea..e4edd29 100644 --- a/run.md +++ b/run.md @@ -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 -``` \ No newline at end of file +``` From 4b0c5d89f0d5a7e36deba2fc0f5576234bfbdbe0 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 7 Oct 2021 23:20:15 +0200 Subject: [PATCH 10/10] Date, time, and pep8-naming --- .github/workflows/lint_python.yml | 4 +-- Jarvis2.py | 60 +++++++++++++++++-------------- Jarvis2_4windows.py | 19 +++++----- 3 files changed, 45 insertions(+), 38 deletions(-) mode change 100644 => 100755 Jarvis2.py diff --git a/.github/workflows/lint_python.yml b/.github/workflows/lint_python.yml index 335a50d..d850a6f 100644 --- a/.github/workflows/lint_python.yml +++ b/.github/workflows/lint_python.yml @@ -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 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 ef5c3d5..0294c51 100644 --- a/Jarvis2_4windows.py +++ b/Jarvis2_4windows.py @@ -49,7 +49,7 @@ def speak(text): engine.runAndWait() -def wishMe(): +def wish_me(): hour = datetime.datetime.now().hour # print(hour) if hour >= 0 and hour < 12: @@ -65,14 +65,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") @@ -84,15 +84,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(): @@ -103,13 +102,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() @@ -126,12 +125,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()