Skip to content

Instantly share code, notes, and snippets.

@simrit1
Forked from adameubanks/PyDa.py
Created July 28, 2021 04:17
Show Gist options
  • Save simrit1/077ec53813dda0c8221c86f67c0114e9 to your computer and use it in GitHub Desktop.
Save simrit1/077ec53813dda0c8221c86f67c0114e9 to your computer and use it in GitHub Desktop.
Code for the video where we build a Jarvis like virtual assistant in python 3
import wolframalpha
client = wolframalpha.Client("lilpumpsaysnopeeking")
import wikipedia
import PySimpleGUI as sg
sg.theme('DarkPurple')
layout =[[sg.Text('Enter a command'), sg.InputText()],[sg.Button('Ok'), sg.Button('Cancel')]]
window = sg.Window('PyDa', layout)
import pyttsx3
engine = pyttsx3.init()
while True:
event, values = window.read()
if event in (None, 'Cancel'):
break
try:
wiki_res = wikipedia.summary(values[0], sentences=2)
wolfram_res = next(client.query(values[0]).results).text
engine.say(wolfram_res)
sg.PopupNonBlocking("Wolfram Result: "+wolfram_res,"Wikipedia Result: "+wiki_res)
except wikipedia.exceptions.DisambiguationError:
wolfram_res = next(client.query(values[0]).results).text
engine.say(wolfram_res)
sg.PopupNonBlocking(wolfram_res)
except wikipedia.exceptions.PageError:
wolfram_res = next(client.query(values[0]).results).text
engine.say(wolfram_res)
sg.PopupNonBlocking(wolfram_res)
except:
wiki_res = wikipedia.summary(values[0], sentences=2)
engine.say(wiki_res)
sg.PopupNonBlocking(wiki_res)
engine.runAndWait()
print (values[0])
window.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment