Skip to content

Instantly share code, notes, and snippets.

@akincan-kilic
Forked from adameubanks/PyDa.py
Created July 25, 2020 08:04
Show Gist options
  • Save akincan-kilic/fec3a2fbac8bacedaad1698ca20c80b6 to your computer and use it in GitHub Desktop.
Save akincan-kilic/fec3a2fbac8bacedaad1698ca20c80b6 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