Created
September 12, 2020 07:32
-
-
Save Dipeshpal/7e1e303b32a5e9f0fcf4b2cf5779a946 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import JarvisAI | |
import re | |
import pprint | |
import random | |
obj = JarvisAI.JarvisAssistant() | |
def t2s(text): | |
obj.text2speech(text) | |
while True: | |
res = obj.mic_input() | |
if re.search('weather|temperature', res): | |
city = res.split(' ')[-1] | |
weather_res = obj.weather(city=city) | |
print(weather_res) | |
t2s(weather_res) | |
if re.search('news', res): | |
news_res = obj.news() | |
pprint.pprint(news_res) | |
t2s(f"I have found {len(news_res)} news. You can read it. Let me tell you first 2 of them") | |
t2s(news_res[0]) | |
t2s(news_res[1]) | |
if re.search('tell me about', res): | |
topic = res.split(' ')[-1] | |
wiki_res = obj.tell_me(topic) | |
print(wiki_res) | |
t2s(wiki_res) | |
if re.search('date', res): | |
date = obj.tell_me_date() | |
print(date) | |
print(t2s(date)) | |
if re.search('time', res): | |
time = obj.tell_me_time() | |
print(time) | |
t2s(time) | |
if re.search('open', res): | |
domain = res.split(' ')[-1] | |
open_result = obj.website_opener(domain) | |
print(open_result) | |
if re.search('launch', res): | |
dict_app = { | |
'chrome': 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe', | |
'epic games': 'C:\Program Files (x86)\Epic Games\Launcher\Portal\Binaries\Win32\EpicGamesLauncher.exe' | |
} | |
app = res.split(' ', 1)[1] | |
path = dict_app.get(app) | |
if path is None: | |
t2s('Application path not found') | |
print('Application path not found') | |
else: | |
t2s('Launching: ' + app) | |
obj.launch_any_app(path_of_app=path) | |
if re.search('hello', res): | |
print('Hi') | |
t2s('Hi') | |
if re.search('how are you', res): | |
li = ['good', 'fine', 'great'] | |
response = random.choice(li) | |
print(f"I am {response}") | |
t2s(f"I am {response}") | |
if re.search('your name|who are you', res): | |
print("My name is Jarvis, I am your personal assistant") | |
t2s("My name is Jarvis, I am your personal assistant") | |
if re.search('what can you do', res): | |
li_commands = { | |
"open websites": "Example: 'open youtube.com", | |
"time": "Example: 'what time it is?'", | |
"date": "Example: 'what date it is?'", | |
"launch applications": "Example: 'launch chrome'", | |
"tell me": "Example: 'tell me about India'", | |
"weather": "Example: 'what weather/temperature in Mumbai?'", | |
"news": "Example: 'news for today' ", | |
} | |
ans = """I can do lots of things, for example you can ask me time, date, weather in your city, | |
I can open websites for you, launch application and more. See the list of commands-""" | |
print(ans) | |
pprint.pprint(li_commands) | |
t2s(ans) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment