Upload python File

parent 1010d0d1
import webbrowser
import wikipedia
import wolframalpha
import speech_recognition as sr
import os
from gtts import gTTS
import wx
text1 = "Welcome IntelJr! Hello I am minoli - the IntelJr Assitant. How can I help you? "
text2 = "Here is the answer you searched for :"
language = "en"
myobj1 = gTTS(text=text1, lang=language, slow=False)
myobj2 = gTTS(text=text2, lang=language, slow=False)
myobj1.save("welcome.mp3")
myobj2.save("Answer.mp3")
app_id = '26Q368-9Q9ERTXHP6'
client = wolframalpha.Client(app_id)
class MyFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None,
pos=wx.DefaultPosition, size=wx.Size(450, 100),
style=wx.MAXIMIZE_BOX | wx.SYSTEM_MENU | wx.CAPTION |
wx.CLOSE_BOX | wx.CLIP_CHILDREN,
title="INTELJR")
panel = wx.Panel(self)
my_sizer = wx.BoxSizer(wx.VERTICAL)
lbl = wx.StaticText(panel,
label="Hello I am minoli- the IntelJR 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()
os.system(" start Welcome.mp3")
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 results from Google Speech Recognition service; {0}".format(e))
string_query = input.split(' ')
first_word = string_query[0]
# noinspection PyBroadException
try:
if first_word == 'open':
website_name = string_query[1]
url = "https://www." + website_name + ".com"
webbrowser.open_new_tab(url)
if input == 'open my college website':
url3 = "https://www.tcetmumbai.in/"
webbrowser.open_new_tab(url3)
# if input == 'open google':
#
# url = "http://google.com"
# webbrowser.open(url, new=2)
# elif input == 'open youtube':
#
# url2 = "http://youtube.com"
# webbrowser.open(url2, new=2)
# elif input == 'open linkedin':
#
# url4 = "http://linkedin.com"
# webbrowser.open_new_tab(url4)
# else:
# print("Invalid input. Please try again.")
else:
res = client.query(input)
answer = next(res.results).text
print(answer)
os.system("start Answer.mp3")
text3 = answer
myobj3 = gTTS(text=text3, lang=language, slow=False)
myobj3.save("Response.mp3")
os.system("start Response.mp3")
except:
# noinspection PyBroadException
try:
input = input.split(' ')
input = ' '.join(input[2:])
print(wikipedia.summary(input))
os.system("start Answer.mp3")
except:
print(" ")
if __name__ == "__main__":
app = wx.App(True)
frame = MyFrame()
app.MainLoop()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment