From 70f3ae325b62fdd689ddda6bfb710b8393688cef Mon Sep 17 00:00:00 2001 From: Aditi Sneh <56735634+aditisneh@users.noreply.github.com> Date: Thu, 1 Oct 2020 20:51:50 +0530 Subject: [PATCH 1/2] Create PyDa.py --- PyDa.py | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 PyDa.py diff --git a/PyDa.py b/PyDa.py new file mode 100644 index 0000000..88b56e7 --- /dev/null +++ b/PyDa.py @@ -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 = "your id" + 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() From ca7ffc9dcf2039d4744bf8194565343d65350573 Mon Sep 17 00:00:00 2001 From: Aditi Date: Thu, 1 Oct 2020 21:20:09 +0530 Subject: [PATCH 2/2] Added PyDa - a Python digital assistant --- PyDa/README.md | 1 + PyDa.py => PyDa/main.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 PyDa/README.md rename PyDa.py => PyDa/main.py (97%) diff --git a/PyDa/README.md b/PyDa/README.md new file mode 100644 index 0000000..2a5762e --- /dev/null +++ b/PyDa/README.md @@ -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. \ No newline at end of file diff --git a/PyDa.py b/PyDa/main.py similarity index 97% rename from PyDa.py rename to PyDa/main.py index 88b56e7..b9fde6b 100644 --- a/PyDa.py +++ b/PyDa/main.py @@ -40,7 +40,7 @@ def OnEnter(self, event): else: try: # wolframalpha - app_id = "your id" + app_id = "Y8PWAH-3KTUK5K8U3" client = wolframalpha.Client(app_id) res = client.query(input) answer = next(res.results).text