예제 #1
0
 def presentPossibleUsers(self, persons, language):
     root = UIAddViews(self.refId)
     root.dialogPhase = root.DialogPhaseClarificationValue
     utterance = UIAssistantUtteranceView()
     utterance.dialogIdentifier = "ContactDataResolutionDucs#disambiguateContact"
     utterance.text = responses['select'][language]
     utterance.speakableText = responses['select'][language] 
     utterance.listenAfterSpeaking = True
     root.views = [utterance]
     # create a list with all the possibilities 
     lst = UIDisambiguationList()
     lst.items = []
     lst.speakableSelectionResponse = "OK!"
     lst.listenAfterSpeaking = True
     lst.selectionResponse = "OK"
     root.views.append(lst)
     for person in persons:
         item = UIListItem()
         item.object = person 
         item.selectionResponse = person.fullName
         item.selectionText = person.fullName
         item.title = person.fullName
         item.commands = [SendCommands([StartRequest(False, "^phoneCallContactId^=^urn:ace:{0}".format(person.identifier))])]
         lst.items.append(item)
     return root
예제 #2
0
 def presentPossibleUsers(self, persons, language):
     root = UIAddViews(self.refId)
     root.dialogPhase = root.DialogPhaseClarificationValue
     utterance = UIAssistantUtteranceView()
     utterance.dialogIdentifier = "ContactDataResolutionDucs#disambiguateContact"
     utterance.text = responses['select'][language]
     utterance.speakableText = responses['select'][language]
     utterance.listenAfterSpeaking = True
     root.views = [utterance]
     # create a list with all the possibilities
     lst = UIDisambiguationList()
     lst.items = []
     lst.speakableSelectionResponse = "OK!"
     lst.listenAfterSpeaking = True
     lst.selectionResponse = "OK"
     root.views.append(lst)
     for person in persons:
         item = UIListItem()
         item.object = person
         item.selectionResponse = person.fullName
         item.selectionText = person.fullName
         item.title = person.fullName
         item.commands = [
             SendCommands([
                 StartRequest(
                     False, "^phoneCallContactId^=^urn:ace:{0}".format(
                         person.identifier))
             ])
         ]
         lst.items.append(item)
     return root
예제 #3
0
	def st_deadbody(self, speech, language):
		if language == 'en-GB':
			root = UIAddViews(self.refId)
			root.dialogPhase = root.DialogPhaseClarificationValue
			utterance = UIAssistantUtteranceView()
			utterance.text = "What kind of place were you looking for?"
			utterance.speakableText = "What kind of place were you looking for?"
			utterance.listenAfterSpeaking = True
			root.views = [utterance]
			# create a list with all the possibilities 
			lst = UIDisambiguationList()
			lst.items = []
			lst.speakableSelectionResponse = "OK!"
			lst.listenAfterSpeaking = True
			lst.selectionResponse = "OK"
			listPlaces = ['Swamps', 'Reservoirs', 'Lakes', 'Dumps', 'Mines', 'Metal Foundries']
			root.views.append(lst)
			for gPlac in listPlaces:
				item = UIListItem()
				item.selectionResponse = gPlac
				item.selectionText = gPlac
				item.title = gPlac
				item.commands = [SendCommands(commands=[StartRequest(handsFree=False, utterance=gPlac)])]
				lst.items.append(item)
			self.sendRequestWithoutAnswer(root)
		self.complete_request()
예제 #4
0
 def findPhoneForNumberType(self, person, numberType, language):         
     # first check if a specific number was already requested
     phoneToMessage = None
     if numberType != None:
         # try to find the phone that fits the numberType
         listToMessage = filter(lambda x: x.label == numberType, person.phones)
         if len(listToMessage) == 1:
             phoneToMessage = listToMessage[0]
     else:
         favPhones = filter(lambda y: y.favoriteVoice if hasattr(y, "favoriteVoice") else False, person.phones)
         if len(favPhones) == 1:
             phoneToMessage = favPhones[0]
     if phoneToMessage == None:
         # lets check if there is more than one number
         if len(person.phones) == 1:
             if numberType != None:
                 self.say(errorNumberNotPresent.format(numberTypesLocalized[numberType][language], person.fullName))
             phoneToMessage = person.phones[0]
         else:
             # damn we need to ask the user which one he wants...
             if phoneToMessage == None:
                 root = UIAddViews(self.refId)
                 root.dialogPhase = root.DialogPhaseClarificationValue
                 
                 utterance = UIAssistantUtteranceView()
                 utterance.dialogIdentifier = "ContactDataResolutionDucs#foundAmbiguousPhoneNumberForContact"
                 utterance.speakableText = utterance.text = responses['selectNumber'][language].format(person.fullName)
                 utterance.listenAfterSpeaking = True
                 
                 root.views = [utterance]
                 
                 lst = UIDisambiguationList()
                 lst.items = []
                 lst.speakableSelectionResponse = ""
                 lst.listenAfterSpeaking = True
                 lst.selectionResponse = ""
                 root.views.append(lst)
                 for phone in person.phones:
                     numberType = numberTypesLocalized[phone.label][language] if phone.label in numberTypesLocalized else phone.label
                     item = UIListItem()
                     item.title = ""
                     item.text = u"{0}: {1}".format(numberType, phone.number)
                     item.selectionText = item.text
                     item.speakableText = u"{0}, ".format(numberType)
                     item.object = phone
                     item.commands = [SendCommands(commands=[StartRequest(handsFree=False, utterance=numberType)])]
                     lst.items.append(item)
                     
                 answer = self.getResponseForRequest(root)
                 numberType = self.getNumberTypeForName(answer, language)
                 if numberType != None:
                     matches = filter(lambda x: x.label == numberType, person.phones)
                     if len(matches) == 1:
                         phoneToMessage = matches[0]
                     else:
                         self.say(errorNumberTypes[language])
                 else:
                     self.say(errorNumberTypes[language])
     return phoneToMessage
예제 #5
0
 def googleplaces_body(self, speech, language, regex):
     root = UIAddViews(self.refId)
     root.dialogPhase = root.DialogPhaseClarificationValue
     utterance = UIAssistantUtteranceView()
     utterance.text = responses['select'][language]
     utterance.speakableText = responses['select'][language] 
     utterance.listenAfterSpeaking = True
     root.views = [utterance]
     # create a list with all the possibilities 
     lst = UIDisambiguationList()
     lst.items = []
     lst.speakableSelectionResponse = "OK!"
     lst.listenAfterSpeaking = True
     lst.selectionResponse = "OK"
     listPlaces = ['Swamps', 'Reservoirs', 'Lakes', 'Dumps', 'Mines', 'Churches']
     root.views.append(lst)
     for gPlac in listPlaces:
         item = UIListItem()
         item.selectionResponse = gPlac
         item.selectionText = gPlac
         item.title = gPlac
         item.commands = [SendCommands(commands=[StartRequest(handsFree=False, utterance=gPlac)])]
         lst.items.append(item)
     answer = self.getResponseForRequest(root)
     print answer
     if answer == listPlaces[0]:
         Title = listPlaces[0]
     if answer == listPlaces[1]:
         Title = listPlaces[1]            
     if answer == listPlaces[2]:
         Title = listPlaces[2]
     if answer == listPlaces[3]:
         Title = listPlaces[3]
     if answer == listPlaces[4]:
         Title = listPlaces[4]
     self.GooglePlaceSearch(speech, language, Title) 
예제 #6
0
    def findPhoneForNumberType(self, person, numberType, language):
        # first check if a specific number was already requested
        phoneToMessage = None
        if numberType != None:
            # try to find the phone that fits the numberType
            phoneToMessage = filter(lambda x: x.label == numberType,
                                    person.phones)
        else:
            favPhones = filter(
                lambda y: y.favoriteVoice
                if hasattr(y, "favoriteVoice") else False, person.phones)
            if len(favPhones) == 1:
                phoneToMessage = favPhones[0]
        if phoneToMessage == None:
            # lets check if there is more than one number
            if len(person.phones) == 1:
                if numberType != None:
                    self.say(
                        errorNumberNotPresent.format(
                            numberTypesLocalized[numberType][language],
                            person.fullName))
                phoneToMessage = person.phones[0]
            else:
                # damn we need to ask the user which one he wants...
                while (phoneToMessage == None):
                    root = UIAddViews(self.refId)
                    root.dialogPhase = root.DialogPhaseClarificationValue

                    utterance = UIAssistantUtteranceView()
                    utterance.dialogIdentifier = "ContactDataResolutionDucs#foundAmbiguousPhoneNumberForContact"
                    utterance.speakableText = utterance.text = responses[
                        'selectNumber'][language].format(person.fullName)
                    utterance.listenAfterSpeaking = True

                    root.views = [utterance]

                    lst = UIDisambiguationList()
                    lst.items = []
                    lst.speakableSelectionResponse = "OK!"
                    lst.listenAfterSpeaking = True
                    lst.selectionResponse = "OK"
                    root.views.append(lst)
                    for phone in person.phones:
                        numberType = numberTypesLocalized[phone.label][
                            language] if phone.label in numberTypesLocalized else phone.label
                        item = UIListItem()
                        item.title = ""
                        item.text = u"{0}: {1}".format(numberType,
                                                       phone.number)
                        item.selectionText = item.text
                        item.speakableText = u"{0}  ".format(numberType)
                        item.object = phone
                        item.commands = [
                            SendCommands(commands=[
                                StartRequest(handsFree=False,
                                             utterance=numberType)
                            ])
                        ]
                        lst.items.append(item)

                    answer = self.getResponseForRequest(root)
                    numberType = self.getNumberTypeForName(answer, language)
                    if numberType != None:
                        matches = filter(lambda x: x.label == numberType,
                                         person.phones)
                        if len(matches) == 1:
                            phoneToMessage = matches[0]
                        else:
                            self.say(errorNumberTypes[language])
                    else:
                        self.say(errorNumberTypes[language])
        return phoneToMessage