Skip to content

A python digital assistant #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions PyDa/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PyDa is a python digital assisstant that hold the capability to answer questions from maths to history . This feature is possible because of the Wolfram Alpha API and the inclusion of wikipedia module. PyDa also has voice recognition feature.
59 changes: 59 additions & 0 deletions PyDa/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import wx
import wikipedia
import wolframalpha
import pyttsx3
import speech_recognition as sr

pyttsx3.speak("Hello I am PyDa,your Python Digital Assistant How can I help you?")
class MyFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None,
pos=wx.DefaultPosition, size=wx.Size(450, 100),
style=wx.MINIMIZE_BOX | wx.SYSTEM_MENU | wx.CAPTION |
wx.CLOSE_BOX | wx.CLIP_CHILDREN,
title="PyDa")
panel = wx.Panel(self)
my_sizer = wx.BoxSizer(wx.VERTICAL)
lbl = wx.StaticText(panel,
label="Hello I am Pyda the Python Digital Assistant. How can I help you?")
my_sizer.Add(lbl, 0, wx.ALL, 5)
self.txt = wx.TextCtrl(panel, style=wx.TE_PROCESS_ENTER,size=(400,30))
self.txt.SetFocus()
self.txt.Bind(wx.EVT_TEXT_ENTER, self.OnEnter)
my_sizer.Add(self.txt, 0, wx.ALL, 5)
panel.SetSizer(my_sizer)
self.Show()

def OnEnter(self, event):
input = self.txt.GetValue()
input = input.lower()
if input =='':
r = sr.Recognizer()
with sr.Microphone() as source:
audio = r.listen(source)
try:
self.txt.SetValue(r.recognize_google(audio))
except sr.UnknownValueError:
print("Google Speech Recognition could not understand audio")
except sr.RequestError as e:
print("Could not request from Google Speech Recognition service; {0}".format(e))
else:
try:
# wolframalpha
app_id = "Y8PWAH-3KTUK5K8U3"
client = wolframalpha.Client(app_id)
res = client.query(input)
answer = next(res.results).text
print(answer)
pyttsx3("Here is the Answer" + answer)
breakpoint()
except:
# wikipedia
pyttsx3.speak("Results for" + input)
print(wikipedia.summary(input))


if __name__ == "__main__":
app = wx.App(True)
frame = MyFrame()
app.MainLoop()