コード例 #1
0
ファイル: __init__.py プロジェクト: castvoid/SiriServerCore
	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()
コード例 #2
0
def CreateListItem(id, mtype):
    item = UIListItem()
    if mtype == 'movie':
       y = json.VideoLibrary.GetMovieDetails(movieid=id, properties=['tagline', 'year', 'rating'])['moviedetails']
       m = [int(id), y['label'], y['year'], y['rating'], y['tagline']]
       item.selectionResponse = "%s (%s)\n\n'%s'" %(m[1], m[2], m[4])
    if mtype == 'album':
       y = json.AudioLibrary.GetAlbumDetails(albumid=id, properties=['title', 'description', 'artist', 'genre', 'year'])['albumdetails']
       m = [int(id), y['title'], y['artist'], y['year'], y['description']]
       item.selectionResponse = "%s (%s)\n\n'%s'" %(m[1], m[3], m[4])
    item.title = "%s (%s)" %(m[1], m[2])
    return item        
コード例 #3
0
ファイル: __init__.py プロジェクト: shan-ge/SiriServerCore
 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 = ""
     lst.listenAfterSpeaking = True
     lst.selectionResponse = ""
     root.views.append(lst)
     for person in persons:
         item = UIListItem()
         item.object = person
         item.selectionResponse = person.fullName
         item.selectionText = person.fullName
         item.speakableText = u"{0}, ".format(person.fullName)
         item.title = person.fullName
         item.commands = [
             SendCommands([
                 StartRequest(
                     False, "^phoneCallContactId^=^urn:ace:{0}".format(
                         person.identifier))
             ])
         ]
         lst.items.append(item)
     return root
コード例 #4
0
ファイル: __init__.py プロジェクト: HengeSense/SiriServerCore
 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 = ""
     lst.listenAfterSpeaking = True
     lst.selectionResponse = ""
     root.views.append(lst)
     for person in persons:
         item = UIListItem()
         item.object = person 
         item.selectionResponse = person.fullName
         item.selectionText = person.fullName
         item.speakableText = u"{0}, ".format(person.fullName)
         item.title = person.fullName
         item.commands = [SendCommands([StartRequest(False, "^phoneCallContactId^=^urn:ace:{0}".format(person.identifier))])]
         lst.items.append(item)
     return root
コード例 #5
0
ファイル: __init__.py プロジェクト: HengeSense/SiriServerCore
 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
コード例 #6
0
ファイル: __init__.py プロジェクト: iron85/SiriServerCore
 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) 
コード例 #7
0
ファイル: __init__.py プロジェクト: imclab/SiriServerPlugins
    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