-
-
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
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 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