예제 #1
0
 def call(self, phone, person, language):
     
     if phone == None:
         print "abandon"
         self.complete_request()
         return
     
     root = ResultCallback(commands=[])
     rootView = AddViews("", temporary=False, dialogPhase="Completion", views=[])
     root.commands.append(rootView)
     rootView.views.append(AssistantUtteranceView(text=responses['callPerson'][language].format(person.fullName, numberTypesLocalized[phone.label][language], phone.number), speakableText=responses['callPersonSpeak'][language].format(person.fullName, numberTypesLocalized[phone.label][language]), dialogIdentifier="PhoneCall#initiatePhoneCall", listenAfterSpeaking=False))
     rootView.callbacks = []
     
     # create some infos of the target
     personAttribute=PersonAttribute(data=phone.number, displayText=person.fullName, obj=Person())
     personAttribute.object.identifer = person.identifier
     call = PhoneCall("", recipient=phone.number, faceTime=False, callRecipient=personAttribute)
     
     rootView.callbacks.append(ResultCallback(commands=[call]))
     
     call.callbacks = []
     # now fill in error messages (airplanemode, no service, invalidNumber, fatal)
     for i in range(4):
         errorRoot = AddViews(None, temporary=False, dialogPhase="Completion", scrollToTop=False, views=[])
         errorRoot.views.append(AssistantUtteranceView(text=errorOnCallResponse[language][i]['text'], speakableText=errorOnCallResponse[language][i]['text'], dialogIdentifier=errorOnCallResponse[language][i]['dialogIdentifier'], listenAfterSpeaking=False))
         call.callbacks.append(ResultCallback(commands=[errorRoot], code=errorOnCallResponse[language][i]['code']))
         
     self.complete_request([root])
예제 #2
0
    def call(self, phone, person, language):

        if phone == None:
            print "abandon"
            self.complete_request()
            return

        root = ResultCallback(commands=[])
        rootView = AddViews("",
                            temporary=False,
                            dialogPhase="Completion",
                            views=[])
        root.commands.append(rootView)
        rootView.views.append(
            AssistantUtteranceView(
                text=responses['callPerson'][language].format(
                    person.fullName,
                    numberTypesLocalized[phone.label][language], phone.number),
                speakableText=responses['callPersonSpeak'][language].format(
                    person.fullName,
                    numberTypesLocalized[phone.label][language]),
                dialogIdentifier="PhoneCall#initiatePhoneCall",
                listenAfterSpeaking=False))
        rootView.callbacks = []

        # create some infos of the target
        personAttribute = PersonAttribute(data=phone.number,
                                          displayText=person.fullName,
                                          obj=Person())
        personAttribute.object.identifer = person.identifier
        call = PhoneCall("",
                         recipient=phone.number,
                         faceTime=False,
                         callRecipient=personAttribute)

        rootView.callbacks.append(ResultCallback(commands=[call]))

        call.callbacks = []
        # now fill in error messages (airplanemode, no service, invalidNumber, fatal)
        for i in range(4):
            errorRoot = AddViews(None,
                                 temporary=False,
                                 dialogPhase="Completion",
                                 scrollToTop=False,
                                 views=[])
            errorRoot.views.append(
                AssistantUtteranceView(
                    text=errorOnCallResponse[language][i]['text'],
                    speakableText=errorOnCallResponse[language][i]['text'],
                    dialogIdentifier=errorOnCallResponse[language][i]
                    ['dialogIdentifier'],
                    listenAfterSpeaking=False))
            call.callbacks.append(
                ResultCallback(commands=[errorRoot],
                               code=errorOnCallResponse[language][i]['code']))

        self.complete_request([root])
    def webSearchConfirmation(self, speech, language, regMatched):
        webSearchQuery = regMatched.group(1)
        webSearchConfirmation = regMatched.group(2)
        
        lang = language.split("-")[0]

        resultCallback1View = AddViews(refId="", views=[AssistantUtteranceView(dialogIdentifier="WebSearch#initiateWebSearch", text=webSearchAnswerText[lang].format(u"„{0}“".format(webSearchQuery)), speakableText=webSearchAnswerText[lang].format(webSearchQuery))])
        
        search = WebSearch(refId="", aceId="", query=webSearchQuery)
        resultCallback3View = AddViews(refId="", views=[AssistantUtteranceView(dialogIdentifier="WebSearch#fatalResponse", text=webSearchAnswerFailureText[lang], speakableText=webSearchAnswerFailureText[lang])])
        resultCallback3 = ResultCallback(commands=[resultCallback3View])
        search.callbacks = [resultCallback3]

        resultCallback2 = ResultCallback(commands=[search])
        resultCallback1View.callbacks = [resultCallback2]

        self.complete_request(callbacks=[ResultCallback(commands=[resultCallback1View])])
예제 #4
0
    def webSearchConfirmation(self, speech, language):
        # lets use a little hack to get that regex
        matcher = self.webSearchConfirmation.__dict__[__criteria_key__]['de-DE']
        regMatched = matcher.match(speech)
        webSearchQuery = regMatched.group(1)
        webSearchConfirmation = regMatched.group(2)
        
        lang = language.split("-")[0]

        resultCallback1View = AddViews(refId="", views=[AssistantUtteranceView(dialogIdentifier="WebSearch#initiateWebSearch", text=webSearchAnswerText[lang].format(u"„{0}“".format(webSearchQuery)), speakableText=webSearchAnswerText[lang].format(webSearchQuery))])
        
        search = WebSearch(refId="", aceId="", query=webSearchQuery)
        resultCallback3View = AddViews(refId="", views=[AssistantUtteranceView(dialogIdentifier="WebSearch#fatalResponse", text=webSearchAnswerFailureText[lang], speakableText=webSearchAnswerFailureText[lang])])
        resultCallback3 = ResultCallback(commands=[resultCallback3View])
        search.callbacks = [resultCallback3]

        resultCallback2 = ResultCallback(commands=[search])
        resultCallback1View.callbacks = [resultCallback2]

        self.complete_request(callbacks=[ResultCallback(commands=[resultCallback1View])])
예제 #5
0
    def webSearchConfirmation(self, speech, language):
        # lets use a little hack to get that regex
        matcher = self.webSearchConfirmation.__dict__[__criteria_key__]['de-DE']
        regMatched = matcher.match(speech)
        webSearchQuery = regMatched.group(1)
        webSearchConfirmation = regMatched.group(2)
        
        lang = language.split("-")[0]

        resultCallback1View = AddViews(refId="", views=[AssistantUtteranceView(dialogIdentifier="WebSearch#initiateWebSearch", text=webSearchAnswerText[lang].format(u"„{0}“".format(webSearchQuery)), speakableText=webSearchAnswerText[lang].format(webSearchQuery))])
        
        search = WebSearch(refId="", aceId="", query=webSearchQuery)
        resultCallback3View = AddViews(refId="", views=[AssistantUtteranceView(dialogIdentifier="WebSearch#fatalResponse", text=webSearchAnswerFailureText[lang], speakableText=webSearchAnswerFailureText[lang])])
        resultCallback3 = ResultCallback(commands=[resultCallback3View])
        search.callbacks = [resultCallback3]

        resultCallback2 = ResultCallback(commands=[search])
        resultCallback1View.callbacks = [resultCallback2]

        self.complete_request(callbacks=[ResultCallback(commands=[resultCallback1View])])