Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0634ffcd6d | |||
| 6e1d61f6a5 |
0
.gitignore
vendored
Normal file
0
.gitignore
vendored
Normal file
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@@ -1,3 +1,2 @@
|
||||
{
|
||||
"python.pythonPath": "C:\\Users\\puran.MANEESHA\\anaconda3\\envs\\alexa\\python.exe"
|
||||
}
|
||||
12
Dockerfile
Normal file
12
Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
||||
FROM python
|
||||
|
||||
WORKDIR /PSMBot-Virtual-Assistant
|
||||
|
||||
COPY /main.py .
|
||||
COPY /weather.py .
|
||||
COPY news.py .
|
||||
|
||||
COPY requirements.txt .
|
||||
RUN pip install requirements.txt
|
||||
|
||||
CMD [ "python", "main.py" ]
|
||||
BIN
__pycache__/news.cpython-38.pyc
Normal file
BIN
__pycache__/news.cpython-38.pyc
Normal file
Binary file not shown.
Binary file not shown.
25
index.md
25
index.md
@@ -1,6 +1,6 @@
|
||||
# **Create your own virtual assistant with just a few lines code (Using only PYTHON)**
|
||||
|
||||
_`Last Updated: December 22' 2020`_
|
||||
_`Last Updated: March 13' 2020`_
|
||||
|
||||
Hello & Welcome to this git page. Here I just created my own
|
||||
virtual assistant with just a few lines of code. It is not an
|
||||
@@ -12,7 +12,7 @@ step by step with me and by the end of it you will have your own
|
||||
virtual assistant up & running as a charm.
|
||||
|
||||
To learn more about how I did it you can watch my YouTube
|
||||
video on this or [click here]().
|
||||
video on this or [click here](https://www.youtube.com/channel/UCz6SDxk2KQqJAD6Ra_YPm6A).
|
||||
|
||||
## Pre-Requisites:
|
||||
1. Python Interpreter (Like [PyCharm](https://www.jetbrains.com/pycharm/))
|
||||
@@ -30,8 +30,13 @@ video on this or [click here]().
|
||||
|
||||
-> [pyjokes](https://pypi.org/project/pyjokes/)
|
||||
|
||||
-> [wolframalpha](https://pypi.org/project/wolframalpha/)
|
||||
|
||||
5. Basic knowledge of how Python works & computers work
|
||||
6. A will to explore
|
||||
7. Get API keys for the following to test your assistant yourself or
|
||||
just use the one I provide you with but it is better to use your API keys
|
||||
so that you don't bottle neck you assistant.
|
||||
|
||||
When all the above pre-requisites are there and ready you can
|
||||
start to work on your own virtual assistant. Please follow each
|
||||
@@ -55,25 +60,31 @@ resolved before opening an issues.
|
||||
|
||||
`pip install pyjokes`
|
||||
|
||||
`pip install wolframalpha`
|
||||
|
||||
|
||||
_Install this if necessary (Only when the code gives error)_
|
||||
|
||||
`pip install pyaudio`
|
||||
|
||||
3. Copy the code given in main.py (in this git) & you will have the code up & running on your pc.
|
||||
_(Note: Creating two different files for weather & main you will have to import weather.py in the main.py file by using the `import weather` code in the main.py, therefore please make sure that the code for it is there or an error will be produced while running the weather command in the assistant.)_
|
||||
4. If you want to learn how this code actually works the go [watch my YouTube video]() for a better understanding.
|
||||
4. If you want to learn how this code actually works the go [watch my YouTube video](https://www.youtube.com/channel/UCz6SDxk2KQqJAD6Ra_YPm6A) for a better understanding.
|
||||
|
||||
### For Linux/MacOs users:
|
||||
|
||||
1. Learn all the above commands on terminal.
|
||||
2. Make sure to use pip3, because in linux pip refers for python2 and pip3 refers to python3.
|
||||
3. Install these too - `pip3 install pyAudio`.
|
||||
3. Install this too - `pip3 install pyAudio`.
|
||||
|
||||
|
||||
## Feature List (v1.0):
|
||||
## Feature List (v2.0):
|
||||
|
||||
1. Play videos on YouTube.
|
||||
2. Search wikipedia with your queries.
|
||||
2. Search Wikipedia with your queries.
|
||||
3. Search google with your queries.
|
||||
4. Listen to jokes.
|
||||
5. Ask for the weather (only New Delhi, India available right now).
|
||||
5. Ask for the weather (Anywhere in the world).
|
||||
6. It can solve complex math problems for you.
|
||||
7. Ask it for today's date & time.
|
||||
8. Say "thanks" or "thank you" and the assistant will appreciate you.
|
||||
54
main.py
54
main.py
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2020 PSMForums. All rights reserved.
|
||||
# Copyright (c) 2021 PSMForums. All rights reserved.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
@@ -16,7 +16,10 @@ import pywhatkit
|
||||
import datetime
|
||||
import wikipedia
|
||||
import pyjokes
|
||||
import wolframalpha
|
||||
import weather
|
||||
import requests, json
|
||||
import pprint
|
||||
|
||||
listener = sr.Recognizer()
|
||||
engine = pyttsx3.init()
|
||||
@@ -61,11 +64,6 @@ if __name__ == "__main__":
|
||||
elif 'time' in command:
|
||||
time = datetime.datetime.now().strftime('%I:%M %p')
|
||||
talk('Current time is ' + time)
|
||||
elif 'search on wikipedia' in command:
|
||||
search = command.replace('search on wikipedia', '')
|
||||
info = wikipedia.summary(search, 6)
|
||||
print('Searching ' + info)
|
||||
talk(info)
|
||||
elif 'search on google' in command:
|
||||
searchg = command.replace('search on google', '')
|
||||
pywhatkit.search(searchg)
|
||||
@@ -77,23 +75,35 @@ if __name__ == "__main__":
|
||||
elif 'joke' in command:
|
||||
talk('Let me get you laughing...')
|
||||
talk(pyjokes.get_joke())
|
||||
elif 'weather' in command:
|
||||
command = command.replace('weather', '')
|
||||
if weather.response.status_code == 200:
|
||||
talk('The Weather In:')
|
||||
talk(weather.weather_city)
|
||||
print(weather.weather_city)
|
||||
talk(weather.weather_temperature)
|
||||
print(weather.weather_temperature)
|
||||
talk(weather.weather_humidity)
|
||||
print(weather.weather_humidity)
|
||||
talk(weather.weather_pressure)
|
||||
print(weather.weather_pressure)
|
||||
talk(weather.weather_report)
|
||||
print(weather.weather_report)
|
||||
elif "what is the weather in" in command:
|
||||
command = command.split(" ")
|
||||
location = str(command[5])
|
||||
url = weather.weather_url + "appid=" + weather.api_key + "&q=" + location
|
||||
js = requests.get(url).json()
|
||||
if js["cod"] != "404":
|
||||
weather = js["main"]
|
||||
temp = weather["temp"]
|
||||
hum = weather["humidity"]
|
||||
desc = js["weather"][0]["description"]
|
||||
resp_string = "The temperature at " + location + " in Kelvin is " + str(temp) + " \nThe humidity is " + str(hum) + "\nand \nThe weather description is "+ str(desc)
|
||||
print(resp_string)
|
||||
talk(resp_string)
|
||||
else:
|
||||
talk(weather.weather_error)
|
||||
print(weather.weather_error)
|
||||
print("City Not Found")
|
||||
talk("City Not Found")
|
||||
elif 'calculate' in command:
|
||||
app_id = "JWP25T-Y434EXL697" #Your API key here
|
||||
client = wolframalpha.Client(app_id)
|
||||
indx = command.lower().split().index('calculate')
|
||||
query = command.split()[indx + 1:]
|
||||
res = client.query(' '.join(query))
|
||||
answer = next(res.results).text
|
||||
print('The answer is ' + answer)
|
||||
talk('The answer is:' + answer)
|
||||
elif 'thank you' in command:
|
||||
talk('Your welcome, Happy to help you')
|
||||
elif 'thanks' in command:
|
||||
talk('Your welcome, Happy to help you')
|
||||
elif 'stop' in command:
|
||||
break
|
||||
else:
|
||||
|
||||
55
news.py
Normal file
55
news.py
Normal file
@@ -0,0 +1,55 @@
|
||||
import pyttsx3
|
||||
import requests
|
||||
import json
|
||||
import time
|
||||
|
||||
url = ('https://newsapi.org/v2/top-headlines?'
|
||||
'country = in&'
|
||||
'apiKey =')
|
||||
|
||||
url += 'e3adedf2b3c54560b27338ef2bac6af8' #Your API key here
|
||||
|
||||
engine = pyttsx3.init()
|
||||
|
||||
voices = engine.getProperty('voices')
|
||||
|
||||
engine.setProperty('voice', voices[1].id)
|
||||
|
||||
rate = engine.getProperty('rate')
|
||||
|
||||
engine.setProperty('rate', 150)
|
||||
|
||||
try:
|
||||
response = requests.get(url)
|
||||
except:
|
||||
engine.talk("can't access link, please check your internet ")
|
||||
|
||||
news = json.loads(response.text)
|
||||
|
||||
for new in news['articles']:
|
||||
# print(str(new['title']), "\n\n")
|
||||
news_title = (str(new['title']))
|
||||
|
||||
# print(str(new['description']), "\n\n")
|
||||
news_description = (str(new['description']))
|
||||
time.sleep(2)
|
||||
|
||||
# from urllib.request import urlopen
|
||||
# from bs4 import BeautifulSoup as soup
|
||||
|
||||
|
||||
# def news():
|
||||
# try:
|
||||
# news_url = "https://news.google.com/news/rss"
|
||||
# Client = urlopen(news_url)
|
||||
# xml_page = Client.read()
|
||||
# Client.close()
|
||||
# soup_page = soup(xml_page, "xml")
|
||||
# news_list = soup_page.findAll("item")
|
||||
# li = []
|
||||
# for news in news_list[:15]:
|
||||
# li.append(str(news.title.text.encode('utf-8'))[1:])
|
||||
# return li
|
||||
# except Exception as e:
|
||||
# print(e)
|
||||
# return False
|
||||
31
notes.txt
Normal file
31
notes.txt
Normal file
@@ -0,0 +1,31 @@
|
||||
# import news
|
||||
# from googlemaps import GoogleMaps
|
||||
|
||||
# elif 'news' in command:
|
||||
# talk(news.news_title)
|
||||
# print(news.news_title + '\n')
|
||||
# print('-----------------------------------------------------------------------------------------\n')
|
||||
# talk(news.news_description)
|
||||
# print(news.news_description + '\n')
|
||||
# print('-----------------------------------------------------------------------------------------\n')
|
||||
|
||||
# print(command)
|
||||
# news_res = command.news()
|
||||
# talk(f"I have found {len(news_res)} news. You can read it. Let me tell you first 2 of them")
|
||||
# talk(news_res[0])
|
||||
# print(news_res[0])
|
||||
# talk(news_res[1])
|
||||
# print(news_res[1])
|
||||
# print(news_res)
|
||||
# elif 'open maps' in command:
|
||||
# command = command.replace('open maps', '')
|
||||
# gmaps = GoogleMaps(api_key)
|
||||
# print('Opening Maps...')
|
||||
# talk('Opening Maps')
|
||||
# print('What do you want to find?')
|
||||
# talk('What do you want to find')
|
||||
# local = gmaps.local_search(destination)
|
||||
|
||||
weather api key = "a4212b9586f6bf848e1c47839ebfc5e9"
|
||||
|
||||
wolframalpha = "JWP25T-Y434EXL697"
|
||||
42
readme.md
42
readme.md
@@ -1,6 +1,6 @@
|
||||
# **Create your own virtual assistant with just a few lines code (Using only PYTHON)**
|
||||
|
||||
_`Last Updated: December 22' 2020`_
|
||||
_`Last Updated: February 05' 2022`_
|
||||
|
||||
Hello & Welcome to this git page. Here I just created my own
|
||||
virtual assistant with just a few lines of code. It is not an
|
||||
@@ -12,9 +12,10 @@ step by step with me and by the end of it you will have your own
|
||||
virtual assistant up & running as a charm.
|
||||
|
||||
To learn more about how I did it you can watch my YouTube
|
||||
video on this or [click here]().
|
||||
video on this or [click here](https://www.youtube.com/channel/UCz6SDxk2KQqJAD6Ra_YPm6A).
|
||||
|
||||
## Pre-Requisites:
|
||||
|
||||
1. Python Interpreter (Like [PyCharm](https://www.jetbrains.com/pycharm/))
|
||||
2. Python Environment (Like [Anaconda](https://www.anaconda.com/products/individual))
|
||||
3. This [git repo](https://github.com/psavarmattas/PSMBot-Virtual-Assistant.git)
|
||||
@@ -26,12 +27,15 @@ video on this or [click here]().
|
||||
|
||||
-> [pywhatkit](https://pypi.org/project/pywhatkit/)
|
||||
|
||||
-> [wikipedia](https://pypi.org/project/wikipedia/)
|
||||
|
||||
-> [pyjokes](https://pypi.org/project/pyjokes/)
|
||||
|
||||
-> [wolframalpha](https://pypi.org/project/wolframalpha/)
|
||||
|
||||
5. Basic knowledge of how Python works & computers work
|
||||
6. A will to explore
|
||||
7. Get API keys for the following to test your assistant yourself or
|
||||
just use the one I provide you with but it is better to use your API keys
|
||||
so that you don't bottle neck you assistant.
|
||||
|
||||
When all the above pre-requisites are there and ready you can
|
||||
start to work on your own virtual assistant. Please follow each
|
||||
@@ -42,18 +46,11 @@ resolved before opening an issues.
|
||||
## Steps:
|
||||
|
||||
### For Windows users:
|
||||
|
||||
1. Open PyCharm & create a new project with your virtual environment ready.
|
||||
2. Open the terminal and paste the following in sequential order line by line(Execute it one by one):
|
||||
2. Open the terminal and paste the command highlighted below:
|
||||
|
||||
`pip install speechRecognistion`
|
||||
|
||||
`pip install pyttsx3`
|
||||
|
||||
`pip install pywhatkit`
|
||||
|
||||
`pip install wikipedia`
|
||||
|
||||
`pip install pyjokes`
|
||||
`pip install -r requirements.txt `
|
||||
|
||||
_Install this if necessary (Only when the code gives error)_
|
||||
|
||||
@@ -61,19 +58,22 @@ _Install this if necessary (Only when the code gives error)_
|
||||
|
||||
3. Copy the code given in main.py (in this git) & you will have the code up & running on your pc.
|
||||
_(Note: Creating two different files for weather & main you will have to import weather.py in the main.py file by using the `import weather` code in the main.py, therefore please make sure that the code for it is there or an error will be produced while running the weather command in the assistant.)_
|
||||
4. If you want to learn how this code actually works the go [watch my YouTube video]() for a better understanding.
|
||||
4. If you want to learn how this code actually works the go [watch my YouTube video](https://www.youtube.com/channel/UCz6SDxk2KQqJAD6Ra_YPm6A) for a better understanding.
|
||||
|
||||
### For Linux/MacOs users:
|
||||
|
||||
1. Learn all the above commands on terminal.
|
||||
2. Make sure to use pip3, because in linux pip refers for python2 and pip3 refers to python3.
|
||||
3. Install these too - `pip3 install pyAudio`.
|
||||
3. Install this too - `pip3 install pyAudio`.
|
||||
|
||||
|
||||
## Feature List (v1.0):
|
||||
## Feature List (v2.0):
|
||||
|
||||
1. Play videos on YouTube.
|
||||
2. Search wikipedia with your queries.
|
||||
3. Search google with your queries.
|
||||
4. Listen to jokes.
|
||||
5. Ask for the weather (only New Delhi, India available right now).
|
||||
2. Search google with your queries.
|
||||
3. Listen to jokes.
|
||||
4. Ask for the weather (Anywhere in the world).
|
||||
5. It can solve complex math problems for you.
|
||||
6. Ask it for today's date & time.
|
||||
7. Say "thanks" or "thank you" and the assistant will appreciate you.
|
||||
8. One command requirements install.
|
||||
40
requirements.txt
Normal file
40
requirements.txt
Normal file
@@ -0,0 +1,40 @@
|
||||
astroid @ file:///C:/ci/astroid_1639044403229/work
|
||||
beautifulsoup4==4.9.3
|
||||
certifi==2021.10.8
|
||||
chardet==4.0.0
|
||||
colorama @ file:///tmp/build/80754af9/colorama_1607707115595/work
|
||||
comtypes==1.1.8
|
||||
idna==2.10
|
||||
isort @ file:///tmp/build/80754af9/isort_1628603791788/work
|
||||
jaraco.context==4.0.0
|
||||
lazy-object-proxy @ file:///C:/ci/lazy-object-proxy_1616529307648/work
|
||||
mccabe==0.6.1
|
||||
more-itertools==8.7.0
|
||||
MouseInfo==0.1.3
|
||||
Pillow==8.1.2
|
||||
platformdirs @ file:///tmp/build/80754af9/platformdirs_1638968569495/work
|
||||
PyAudio==0.2.11
|
||||
PyAutoGUI==0.9.52
|
||||
PyGetWindow==0.0.9
|
||||
pyjokes==0.6.0
|
||||
pylint @ file:///C:/ci/pylint_1639650750934/work
|
||||
PyMsgBox==1.0.9
|
||||
pyperclip==1.8.2
|
||||
pypiwin32==223
|
||||
PyRect==0.1.4
|
||||
PyScreeze==0.1.26
|
||||
pyttsx3==2.90
|
||||
PyTweening==1.0.3
|
||||
pywhatkit==3.9
|
||||
pywin32==300
|
||||
requests==2.25.1
|
||||
six @ file:///tmp/build/80754af9/six_1623709665295/work
|
||||
soupsieve==2.2
|
||||
SpeechRecognition==3.8.1
|
||||
toml @ file:///tmp/build/80754af9/toml_1616166611790/work
|
||||
typing-extensions @ file:///tmp/build/80754af9/typing_extensions_1631814937681/work
|
||||
urllib3==1.26.3
|
||||
wincertstore==0.2
|
||||
wolframalpha==5.0.0
|
||||
wrapt @ file:///C:/ci/wrapt_1638434029846/work
|
||||
xmltodict==0.12.0
|
||||
54
weather.py
54
weather.py
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2020 PSMForums. All rights reserved.
|
||||
# Copyright (c) 2021 PSMForums. All rights reserved.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
@@ -9,52 +9,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# importing requests and json
|
||||
import requests, json
|
||||
# API Key
|
||||
api_key = "a4212b9586f6bf848e1c47839ebfc5e9" #Your API Key here
|
||||
|
||||
# base URL
|
||||
BASE_URL = "https://api.openweathermap.org/data/2.5/weather?"
|
||||
|
||||
# City Name
|
||||
CITY = "New Delhi"
|
||||
|
||||
# API key
|
||||
API_KEY = "a4212b9586f6bf848e1c47839ebfc5e9"
|
||||
|
||||
# Updating the URL
|
||||
URL = BASE_URL + "q=" + CITY + "&appid=" + API_KEY
|
||||
|
||||
# HTTP request
|
||||
response = requests.get(URL)
|
||||
|
||||
# checking the status code of the request
|
||||
|
||||
if response.status_code == 200:
|
||||
|
||||
# getting data in the json format
|
||||
data = response.json()
|
||||
|
||||
# getting the main dict block
|
||||
main = data['main']
|
||||
|
||||
# getting temperature
|
||||
temperature = main['temp']
|
||||
|
||||
# getting the humidity
|
||||
humidity = main['humidity']
|
||||
|
||||
# getting the pressure
|
||||
pressure = main['pressure']
|
||||
|
||||
# weather report
|
||||
|
||||
report = data['weather']
|
||||
weather_city = f"{CITY:-^30}"
|
||||
weather_temperature = f"Temperature: {temperature}"
|
||||
weather_humidity = f"Humidity: {humidity}"
|
||||
weather_pressure = f"Pressure: {pressure}"
|
||||
weather_report = f"Weather Report: {report[0]['description']}"
|
||||
|
||||
else:
|
||||
# showing the error message
|
||||
weather_error = "Error in the HTTP request please try again"
|
||||
# Base URL
|
||||
weather_url = "http://api.openweathermap.org/data/2.5/weather?"
|
||||
|
||||
Reference in New Issue
Block a user