def FreeSlots(output): try: entities = output['entities'] #print(len(entities)) if len(entities) > 0: if entities[0]["type"] == "builtin.datetimeV2.date": startDate = entities[0]["resolution"]["values"][0]["value"] print(startDate) meetings = OM.getMeetingsByDays(startDate,1,None,0) if len(meetings)!=0: freeSlots = OM.GetFreeTimes(OM.GetTimeSlots('shift'),meetings) ReadOutFreeSlots(freeSlots,startDate) else: print("You don't have any meetings") winspeech.say_wait("you don't have any meetings on "+startDate) else: print("Different date type") else: meetings = OM.getMeetingsByDays(None,1,None,0) if len(meetings)!=0: freeSlots = OM.GetFreeTimes(OM.GetTimeSlots('shift'),meetings) ReadOutFreeSlots(freeSlots,None) else: print("You don't have any meetings") winspeech.say_wait("you don't have any meetings") except Exception as e: print("Error in show meetings "+str(e))
def ReadOutFreeSlots(freeSlots,startDate): if startDate == None: startDateSpeak = str(date.today()) else: startDateSpeak = startDate headerText = "You have the following free slots on "+startDateSpeak WFH.WriteToCurrentJson(headerText,"free-slots",freeSlots,reminderNativeAppPath) # totalJsonData = {} # headerList = [] # dataType = [] # headerList.append(headerText) # dataType.append("free-slots") # totalJsonData["dataType"] = dataType # totalJsonData["currentHeader"] = headerList # totalJsonData["currentData"] = freeSlots # WF.WriteToFile(totalJsonData,"currentdata.json") # os.startfile(reminderNativeAppPath) print(headerText) winspeech.say_wait(headerText) for freeSlot in freeSlots: outputString = "from "+freeSlot["Start"] + " to "+freeSlot["End"] print(outputString) winspeech.say_wait(outputString)
def ReadOutMeetings(meetings): print(meetings) headerText = "" if len(meetings) == 0: headerText = "You don't have any meeting." elif len(meetings) == 1: headerText = "You have "+str(len(meetings))+" meeting" else: headerText = "You have "+str(len(meetings))+" meetings" WFH.WriteToCurrentJson(headerText,"meetings",meetings,reminderNativeAppPath) # totalJsonData = {} # headerList = [] # dataType = [] # headerList.append(headerText) # dataType.append("meetings") # totalJsonData["dataType"] = dataType # totalJsonData["currentHeader"] = headerList # totalJsonData["currentData"] = meetings # WF.WriteToFile(totalJsonData,"currentdata.json") # os.startfile(reminderNativeAppPath) print(headerText) winspeech.say_wait(headerText) for meeting in meetings: outputString = "Meeting Subject is: "+meeting["Subject"] + ", Meeting Organizer is: "+meeting["Organizer"] + ", Meeting is from "+datetime.strptime(meeting['Start'], '%m/%d/%Y %I:%M %p').strftime('%I:%M %p')+" to "+datetime.strptime(meeting['End'], '%m/%d/%Y %I:%M %p').strftime('%I:%M %p')+" at "+meeting["Location"]+"." print(outputString) winspeech.say_wait(outputString)
def ParseIntent(output): try: topScoringIntent = output['topScoringIntent']['intent'] print(topScoringIntent) if topScoringIntent == "openApplication": AHD.OpenApplicationParser(output) # elif topScoringIntent=="writeMail": # WriteEmailParser(output) elif topScoringIntent == "showMeetings": OD.ShowMeetings(output) elif topScoringIntent == "freeSlots": OD.FreeSlots(output) elif topScoringIntent == "GreetingIntent": winspeech.say_wait("Hi, how can I help you today?") elif topScoringIntent == "Reminder.Create": RD.CreateReminderDialog(output) elif topScoringIntent == "Reminder.Find": RD.FindReminders(output) elif topScoringIntent == "writeMail": OD.CreateEmail(output) except Exception as e: print("Error in intent parsing " + str(e))
def AppendToFile(currentData): with open('data.json') as json_file: data = json.load(json_file) data['reminders'].append(currentData) with open('data.json', 'w') as outfile: json.dump(data, outfile) print("Ok, your reminder is saved") winspeech.say_wait("Ok, your reminder is saved")
def OpenApplication(applicationDisplayName, allApplicationList): try: os.startfile(allApplicationList[applicationDisplayName]) print("Okay, Opening " + applicationDisplayName) winspeech.say_wait("Okay, Opening " + applicationDisplayName) except: print("Could not find the application you are asking for.") winspeech.say_wait( "Could not find the application you are asking for.")
def CreateForwardLoop(previousText, queryText): print(queryText) winspeech.say_wait(queryText) if config.voiceEnable == True: reminderAdditionalInput = GSTT.getSpeechToText() else: reminderAdditionalInput = input(" : ") luisOutput = luis.AnalyseIntent(previousText + reminderAdditionalInput) return CreateReminder(luisOutput)
def OpenApplicationParser(output): entities = output['entities'] applicattionNameInput = "" if len(entities) > 0: entity = entities[0]["entity"].lower() applicattionNameInput = entity else: print("Please provide the application name: ") winspeech.say_wait("Please provide the application name: ") if config.voiceEnable == True: speechResult = GSTT.getSpeechToText() else: speechResult = input(" : ") applicattionNameInput = speechResult OpenApplication(applicattionNameInput, installedApplicationMaps)
def respond(phrase, prepend_positive_response=False, override_subtitle=False, say_wait=False): """ Call this method to make Freya respond Parameters: phrase: The phrase to say. prepend_positive_response: A boolean denoting whether or not to prepend a positive response to the phrase. False by default. override_subtitle: If true the subtitle will be printed not matter what the preference is set to. Use it wisely. say_wait: Will use the customized winspeech module's say_wait() method instead of say() """ if prepend_positive_response: phrase = _get_positive_response() + " " + phrase phrase = phrase.lower().capitalize() # Fix stuff if preferences.get_print_subtitle(): print("Freya: " + phrase + "\n") if say_wait: winspeech.say_wait(phrase) return winspeech.say(phrase)
def CreateEmail(output): try: entities = output['entities'] #print(len(entities)) if len(entities) > 0: print("Entitites") else: print("Please provide the recipient email") winspeech.say_wait("Please provide the recipient email") userInputMailId = GSTT.getSpeechToText() recipient = OCH.CheckEmailMatch(userInputMailId) print(recipient) print("Please prove the Subject of the email") winspeech.say_wait("Please provide the Subject of the email") userEmailSubject = GSTT.getSpeechToText() print("Okay, opening new email") winspeech.say("Please wait while opening new email") OCH.CreateEmail(recipient["email"],userEmailSubject) except Exception as e: print("Error in show create mail "+str(e))
def ReadOutReminders(reminders): reminderHeader = "" if len(reminders) == 0: reminderHeader = "You don't have any reminder" elif len(reminders) == 1: reminderHeader = "You have one reminder" else: reminderHeader = "You have " + str(len(reminders)) + " reminders" WFH.WriteToCurrentJson(reminderHeader, "reminder", reminders, reminderNativeAppPath) # totalJsonData = {} # headerList = [] # dataType = [] # headerList.append(reminderHeader) # dataType.append("reminder") # totalJsonData["dataType"] = dataType # totalJsonData["currentHeader"] = headerList # totalJsonData["currentData"] = reminders # WF.WriteToFile(totalJsonData,"currentdata.json") # os.startfile(reminderNativeAppPath) print(reminderHeader) winspeech.say_wait(reminderHeader) for reminder in reminders: currentDateTimeObject = datetime.strptime(reminder["reminderDateTime"], '%Y-%m-%d %H:%M:%S') changedDateTimeFormat = currentDateTimeObject.strftime('%I:%M %p') outputString = reminder["reminderText"] + " at " + changedDateTimeFormat print(outputString) winspeech.say_wait(outputString)
def CreateReminderDialog(output): reminder = CreateReminder(output) print(reminder) winspeech.say_wait("your reminder text is " + reminder["reminderText"] + ", reminder is set on " + reminder["reminderDateTime"] + " .") print("please say confirm to save it and say cancel to dismiss.") winspeech.say_wait( "please say confirm to save it and say cancel to dismiss.") if config.voiceEnable == True: userInput = GSTT.getSpeechToText() else: userInput = input(" : ") if userInput == "confirm": WF.AppendToFile(reminder) else: print("Ok, dismissing it") winspeech.say_wait("ok, dismissing it")
def wecome(): winspeech.say_wait("WellCome mad, I am Your personar assistant. How can I help you madam") return 0
import winspeech str = "This is the national entham, i know you" winspeech.say_wait(str)
import pyttsx3 import winspeech engine = pyttsx3.init() rate = engine.getProperty('rate') engine.setProperty('rate', rate + 20) engine.say("Hello madam, I am at your services, How can I help you, madam?") engine.runAndWait() winspeech.say_wait( "Hello sir , I am at your services, Ho can I help you, sir?")
def say(take): winspeech.say_wait(take) return
def foo(): winspeech.say_wait("hello adil sir , how are you?")
from chatterbot import ChatBot from chatterbot.trainers import ListTrainer import winspeech import os bot=ChatBot('Bot') bot.set_trainer(ListTrainer) for files in os.listdir('C:/chatterbot-corpus-master/chatterbot_corpus/data/english/'): data=open('C:/chatterbot-corpus-master/chatterbot_corpus/data/english/'+files,'r').readlines() bot.train(data) while True: message = input('You :') winspeech.say(message) if message.strip()!='bye': reply = bot.get_response(message) print('Chatbot :', reply) winspeech.say(reply) if message.strip()=='bye': print('Chatbot : bye, see you again.') winspeech.say_wait("bye,see you again") break