Merge branch 'main' into newfeature
This commit is contained in:
commit
426c70e4b8
6
.github/workflows/lint_python.yml
vendored
6
.github/workflows/lint_python.yml
vendored
@ -7,11 +7,11 @@ jobs:
|
|||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: actions/setup-python@v2
|
- uses: actions/setup-python@v2
|
||||||
- run: pip install --upgrade pip wheel
|
- run: pip install --upgrade pip wheel
|
||||||
- run: pip install bandit black codespell flake8 flake8-bugbear
|
- run: pip install bandit black codespell flake8 flake8-bugbear flake8-comprehensions
|
||||||
flake8-comprehensions isort mypy pytest pyupgrade safety
|
flake8-return isort mypy pep8-naming pytest pyupgrade safety
|
||||||
- run: bandit --recursive --skip B311,B605 .
|
- run: bandit --recursive --skip B311,B605 .
|
||||||
- run: black --check . || true
|
- 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: flake8 . --count --max-complexity=19 --max-line-length=88 --show-source --statistics
|
||||||
- run: isort --check-only --profile black .
|
- run: isort --check-only --profile black .
|
||||||
- run: pip install -r requirements.txt || pip install --editable . || true
|
- run: pip install -r requirements.txt || pip install --editable . || true
|
||||||
|
|||||||
60
Jarvis2.py
Normal file → Executable file
60
Jarvis2.py
Normal file → Executable file
@ -1,4 +1,7 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
import getpass
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
import smtplib
|
import smtplib
|
||||||
@ -10,12 +13,12 @@ import speech_recognition as sr
|
|||||||
import wikipedia
|
import wikipedia
|
||||||
|
|
||||||
print("Initializing Jarvis....")
|
print("Initializing Jarvis....")
|
||||||
MASTER = "Harsha"
|
MASTER = getpass.getuser()
|
||||||
|
|
||||||
|
|
||||||
engine = pyttsx3.init("nsss")
|
engine = pyttsx3.init("nsss")
|
||||||
voices = engine.getProperty("voices")
|
voices = engine.getProperty("voices")
|
||||||
engine.setProperty("voice", voices[0].id)
|
engine.setProperty("voice", voices[0].id)
|
||||||
|
|
||||||
popular_websites = {
|
popular_websites = {
|
||||||
"google": "https://www.google.com",
|
"google": "https://www.google.com",
|
||||||
"youtube": "https://www.youtube.com",
|
"youtube": "https://www.youtube.com",
|
||||||
@ -47,15 +50,17 @@ def speak(text):
|
|||||||
engine.runAndWait()
|
engine.runAndWait()
|
||||||
|
|
||||||
|
|
||||||
def wishMe():
|
def print_and_speak(text):
|
||||||
|
print(text)
|
||||||
|
speak(text)
|
||||||
|
|
||||||
|
|
||||||
|
def wish_me():
|
||||||
hour = datetime.datetime.now().hour
|
hour = datetime.datetime.now().hour
|
||||||
# print(hour)
|
if hour < 12:
|
||||||
if hour >= 0 and hour < 12:
|
|
||||||
speak("Good Morning" + MASTER)
|
speak("Good Morning" + MASTER)
|
||||||
|
elif hour < 18:
|
||||||
elif hour >= 12 and hour < 18:
|
|
||||||
speak("Good Afternoon" + MASTER)
|
speak("Good Afternoon" + MASTER)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
speak("Good Evening" + MASTER)
|
speak("Good Evening" + MASTER)
|
||||||
|
|
||||||
@ -65,50 +70,53 @@ def wishMe():
|
|||||||
# This is where our programme begins....
|
# This is where our programme begins....
|
||||||
|
|
||||||
|
|
||||||
def takeCommand():
|
def take_command():
|
||||||
r = sr.Recognizer()
|
r = sr.Recognizer()
|
||||||
with sr.Microphone() as source:
|
with sr.Microphone() as source:
|
||||||
print("Listening....")
|
print("Listening....")
|
||||||
r.pause_threshold = 0.5
|
r.pause_threshold = 0.5
|
||||||
audio = r.listen(source)
|
audio = r.listen(source)
|
||||||
|
|
||||||
query = " "
|
print("Recognizing....")
|
||||||
|
query = ""
|
||||||
try:
|
try:
|
||||||
print("Recognizing....")
|
|
||||||
query = r.recognize_google(audio, language="en-in")
|
query = r.recognize_google(audio, language="en-in")
|
||||||
print("user said: " + query)
|
print("User said: " + query)
|
||||||
|
|
||||||
except sr.UnknownValueError:
|
except sr.UnknownValueError:
|
||||||
print("Sorry Could You please try again")
|
print("Sorry could you please try again?")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
print("Say That Again Please")
|
print("Say that again, please?")
|
||||||
query = None
|
|
||||||
|
|
||||||
return query
|
return query
|
||||||
|
|
||||||
|
|
||||||
speak("Initializing Jarvis....")
|
speak("Initializing Jarvis....")
|
||||||
wishMe()
|
wish_me()
|
||||||
query = takeCommand()
|
query = take_command().lower()
|
||||||
|
|
||||||
# logic for executing basic tasks
|
# logic for executing basic tasks
|
||||||
if "wikipedia" in query.lower():
|
if "wikipedia" in query.lower():
|
||||||
speak("Searching wikipedia....")
|
speak("Searching wikipedia....")
|
||||||
query = query.replace("wikipedia", "")
|
query = query.replace("wikipedia", "")
|
||||||
results = wikipedia.summary(query, sentences=2)
|
print_and_speak(wikipedia.summary(query, sentences=2))
|
||||||
print(results)
|
|
||||||
speak(results)
|
|
||||||
|
|
||||||
elif "what's up" in query or "how are you" in query:
|
elif "what's up" in query or "how are you" in query:
|
||||||
stMsgs = [
|
st_msgs = (
|
||||||
"Just doing my thing!",
|
"Just doing my thing!",
|
||||||
"I am fine!",
|
"I am fine!",
|
||||||
"Nice!",
|
"Nice!",
|
||||||
"I am nice and full of energy",
|
"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():
|
elif "open" in query.lower():
|
||||||
website = query.replace("open", "").strip().lower()
|
website = query.replace("open", "").strip().lower()
|
||||||
@ -116,7 +124,7 @@ elif "open" in query.lower():
|
|||||||
open_url(popular_websites[website])
|
open_url(popular_websites[website])
|
||||||
except IndexError: # If the website is unknown
|
except IndexError: # If the website is unknown
|
||||||
print(f"Unknown website: {website}")
|
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():
|
elif "search" in query.lower():
|
||||||
search_query = query.split("for")[-1]
|
search_query = query.split("for")[-1]
|
||||||
@ -125,12 +133,12 @@ elif "search" in query.lower():
|
|||||||
|
|
||||||
elif "email" in query:
|
elif "email" in query:
|
||||||
speak("Who is the recipient? ")
|
speak("Who is the recipient? ")
|
||||||
recipient = takeCommand()
|
recipient = take_command()
|
||||||
|
|
||||||
if "me" in recipient:
|
if "me" in recipient:
|
||||||
try:
|
try:
|
||||||
speak("What should I say? ")
|
speak("What should I say? ")
|
||||||
content = takeCommand()
|
content = take_command()
|
||||||
|
|
||||||
server = smtplib.SMTP("smtp.gmail.com", 587)
|
server = smtplib.SMTP("smtp.gmail.com", 587)
|
||||||
server.ehlo()
|
server.ehlo()
|
||||||
|
|||||||
@ -47,6 +47,7 @@ popular_websites = {
|
|||||||
"youtube": "https://www.youtube.com",
|
"youtube": "https://www.youtube.com",
|
||||||
"wikipedia": "https://www.wikipedia.org",
|
"wikipedia": "https://www.wikipedia.org",
|
||||||
"amazon": "https://www.amazon.com",
|
"amazon": "https://www.amazon.com",
|
||||||
|
"GitHub": "https://www.github.com",
|
||||||
}
|
}
|
||||||
search_engines = {
|
search_engines = {
|
||||||
"google": "https://www.google.com",
|
"google": "https://www.google.com",
|
||||||
@ -74,7 +75,7 @@ def speak(text):
|
|||||||
engine.runAndWait()
|
engine.runAndWait()
|
||||||
|
|
||||||
|
|
||||||
def wishMe():
|
def wish_me():
|
||||||
hour = datetime.datetime.now().hour
|
hour = datetime.datetime.now().hour
|
||||||
# print(hour)
|
# print(hour)
|
||||||
if hour >= 0 and hour < 12:
|
if hour >= 0 and hour < 12:
|
||||||
@ -90,14 +91,14 @@ def wishMe():
|
|||||||
|
|
||||||
|
|
||||||
# This is where our programme begins....
|
# This is where our programme begins....
|
||||||
def takeCommand():
|
def take_command():
|
||||||
r = sr.Recognizer()
|
r = sr.Recognizer()
|
||||||
with sr.Microphone() as source:
|
with sr.Microphone() as source:
|
||||||
print("Listening....")
|
print("Listening....")
|
||||||
r.pause_threshold = 0.5
|
r.pause_threshold = 0.5
|
||||||
audio = r.listen(source)
|
audio = r.listen(source)
|
||||||
|
|
||||||
query = " "
|
query = ""
|
||||||
try:
|
try:
|
||||||
print("Recognizing....")
|
print("Recognizing....")
|
||||||
query = r.recognize_google(audio, language="en-in")
|
query = r.recognize_google(audio, language="en-in")
|
||||||
@ -109,15 +110,14 @@ def takeCommand():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
print("Say That Again Please")
|
print("Say That Again Please")
|
||||||
query = None
|
|
||||||
|
|
||||||
return query
|
return query
|
||||||
|
|
||||||
|
|
||||||
speak("Initializing Jarvis....")
|
speak("Initializing Jarvis....")
|
||||||
wishMe()
|
wish_me()
|
||||||
while True:
|
while True:
|
||||||
query = takeCommand()
|
query = take_command()
|
||||||
|
|
||||||
# logic for executing basic tasks
|
# logic for executing basic tasks
|
||||||
if "wikipedia" in query.lower():
|
if "wikipedia" in query.lower():
|
||||||
@ -128,13 +128,13 @@ while True:
|
|||||||
speak(results)
|
speak(results)
|
||||||
|
|
||||||
elif "what's up" in query or "how are you" in query:
|
elif "what's up" in query or "how are you" in query:
|
||||||
stMsgs = [
|
st_msgs = [
|
||||||
"Just doing my thing!",
|
"Just doing my thing!",
|
||||||
"I am fine!",
|
"I am fine!",
|
||||||
"Nice!",
|
"Nice!",
|
||||||
"I am nice and full of energy",
|
"I am nice and full of energy",
|
||||||
]
|
]
|
||||||
speak(random.choice(stMsgs))
|
speak(random.choice(st_msgs))
|
||||||
|
|
||||||
elif "open" in query.lower():
|
elif "open" in query.lower():
|
||||||
website = query.replace("open", "").strip().lower()
|
website = query.replace("open", "").strip().lower()
|
||||||
@ -151,12 +151,12 @@ while True:
|
|||||||
|
|
||||||
elif "mail" in query:
|
elif "mail" in query:
|
||||||
speak("Who is the recipient? ")
|
speak("Who is the recipient? ")
|
||||||
recipient = takeCommand()
|
recipient = take_command()
|
||||||
|
|
||||||
if "me" in recipient:
|
if "me" in recipient:
|
||||||
try:
|
try:
|
||||||
speak("What should I say? ")
|
speak("What should I say? ")
|
||||||
content = takeCommand()
|
content = take_command()
|
||||||
|
|
||||||
server = smtplib.SMTP("smtp.gmail.com", 587)
|
server = smtplib.SMTP("smtp.gmail.com", 587)
|
||||||
server.ehlo()
|
server.ehlo()
|
||||||
|
|||||||
12
README.md
12
README.md
@ -1,10 +1,11 @@
|
|||||||
# DesktopAssitant
|
# Desktop Assistant
|
||||||
|
|
||||||
A Virtual Desktop Assistant Written in Python.
|
A Virtual Desktop Assistant Written in Python.
|
||||||
<br> It's generally a basic virtual assistant
|
<br> It's generally a basic virtual assistant
|
||||||
<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)
|
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>
|
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>
|
||||||
@ -15,6 +16,15 @@ Step2. For windows user run Jarvis2_4windows.py script.
|
|||||||
|
|
||||||
Wow All done! Now give the command to jarvis.
|
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>```
|
||||||
|
- cd into the project directory i.e - ```cd DesktopAssitant```
|
||||||
|
- install requirements.txt ```pip install -r requirements.txt```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 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
|
||||||
|
|||||||
@ -2,3 +2,9 @@ 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
|
||||||
|
PyAudio==0.2.11
|
||||||
|
pygame==2.0.1
|
||||||
|
pyttsx3==2.90
|
||||||
|
SpeechRecognition==3.8.1
|
||||||
|
wikipedia==1.4.0
|
||||||
|
|
||||||
|
|||||||
80
run.md
Normal file
80
run.md
Normal file
@ -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 <br>](#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 -->
|
||||||
|
- 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 <br>
|
||||||
|
|
||||||
|
- 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
|
||||||
|
```
|
||||||
Loading…
x
Reference in New Issue
Block a user