Exemplo n.º 1
0
    def locationTest(self, _text):
        '''This is an example of a speech rule which triggers when
        the user says "Create map location ".

        This example demonstrates how create and display a specific
        map location to the Siri user.

        * _text -- The text spoken by the user

        '''
        # Create the two web search buttons to display to the user
        locations = [
            ("Apple HQ", ObjectFactory.location(street="1 Infinite Loop",
                                                city="Cupertino",
                                                stateCode="CA",
                                                countryCode="US",
                                                postalCode="95014")),
            ("Orlando", ObjectFactory.location(city="Olando", stateCode="FL",
                                               countryCode="US")),
            ]
        mapItem = ObjectFactory.mapItem(locations)

        # Create a view to display the utterance and the buttons
        self.makeView([mapItem])
        self.completeRequest()
Exemplo n.º 2
0
    def directionsTest(self, _text):
        '''Test creating directions between two locations.

        Note: Currently directions only work between two locations that
              are given the latitude and longitude coordinates.

        '''
        appleHq = ObjectFactory.location(latitude=37.331414,
                                         longitude=-122.030566)
        appleHq = DataObjects.create(DataObjects.MapItem,
                                     label="Apple HQ",
                                     location=appleHq)

        googleHq = ObjectFactory.location(street="1600 Amphitheatre Parkway",
                                          city="Mountain View",
                                          stateCode="CA",
                                          countryCode="US",
                                          postalCode="94043",
                                          latitude=37.422131,
                                          longitude=-122.083911)
        googleHq = DataObjects.create(DataObjects.MapItem,
                                      label="Google HQ",
                                      location=googleHq)

        # Note: Showing directions completes the request
        self.showDrivingDirections(appleHq, googleHq)
Exemplo n.º 3
0
    def buttonTest(self, text):
        """This is an example of a speech rule which triggers when
        the user says "Create a button" or "Make a button".

        This example demonstrates how to display buttons to the user
        which allow the user to perform a web search for specific text.

        * text -- The text spoken by the user

        """
        # Create the two web search buttons to display to the user
        button1 = ObjectFactory.button(Buttons.WebSearch, "Search for Siri", "siri")
        button2 = ObjectFactory.button(Buttons.WebSearch, "Search for Python", "python")

        # Create an utterance to go along with the buttons
        utterance = ObjectFactory.utterance("Look! I made buttons", "Aren't they cool?")

        # Create a view to display the utterance and the buttons
        self.makeView([utterance, button1, button2])
        self.completeRequest()
Exemplo n.º 4
0
    def __createCustomButtons(self):
        """Create a list of buttons that perform custom commands."""
        buttons = []

        # Create buttons to execute custom commands for each of the
        # buttons in the list of buttons
        for buttonText, command in self.__buttonList:
            button = ObjectFactory.button(Buttons.Custom, buttonText, command)
            buttons.append(button)

        return buttons
Exemplo n.º 5
0
        def createCustomButtons():
            '''Create a list of buttons that perform custom commands.'''
            buttons = []

            # Create buttons to execute custom commands for each of the
            # buttons in the list of buttons
            for buttonText, command in self.__buttonList:
                button = ObjectFactory.button(Buttons.Custom, buttonText,
                                              command)
                buttons.append(button)
            return buttons
Exemplo n.º 6
0
    def directionsTest(self, _text):
        '''Test creating directions between two locations.

        Note: Currently directions only work between two locations that
              are given the latitude and longitude coordinates.

        '''
        appleHq = ObjectFactory.location(latitude=37.331414,
                                         longitude=-122.030566)
        appleHq = DataObjects.create(DataObjects.MapItem,
                                     label="Apple HQ", location=appleHq)

        googleHq = ObjectFactory.location(street="1600 Amphitheatre Parkway",
                                          city="Mountain View", stateCode="CA",
                                          countryCode="US", postalCode="94043",
                                          latitude=37.422131,
                                          longitude=-122.083911)
        googleHq = DataObjects.create(DataObjects.MapItem, label="Google HQ",
                                      location=googleHq)

        # Note: Showing directions completes the request
        self.showDrivingDirections(appleHq, googleHq)
Exemplo n.º 7
0
    def buttonTest(self, text):
        '''This is an example of a speech rule which triggers when
        the user says "Create a button" or "Make a button".

        This example demonstrates how to display buttons to the user
        which allow the user to perform a web search for specific text.

        * text -- The text spoken by the user

        '''
        # Create the two web search buttons to display to the user
        button1 = ObjectFactory.button(Buttons.WebSearch, "Search for Siri",
                                       "siri")
        button2 = ObjectFactory.button(Buttons.WebSearch, "Search for Python",
                                       "python")

        # Create an utterance to go along with the buttons
        utterance = ObjectFactory.utterance("Look! I made buttons",
                                            "Aren't they cool?")

        # Create a view to display the utterance and the buttons
        self.makeView([utterance, button1, button2])
        self.completeRequest()
Exemplo n.º 8
0
    def radio(self, text):
        def createCustomButtons():
            '''Create a list of buttons that perform custom commands.'''
            buttons = []

            # Create buttons to execute custom commands for each of the
            # buttons in the list of buttons
            for buttonText, command in self.__buttonList:
                button = ObjectFactory.button(Buttons.Custom, buttonText,
                                              command)
                buttons.append(button)
            return buttons

        buttons = createCustomButtons()
        utterance = ObjectFactory.utterance("Welche Station willst du hören?")
        self.makeView([utterance] + buttons)
        self.completeRequest()
Exemplo n.º 9
0
    def radio(self, text):

        def createCustomButtons():
            '''Create a list of buttons that perform custom commands.'''
            buttons = []

            # Create buttons to execute custom commands for each of the
            # buttons in the list of buttons
            for buttonText, command in self.__buttonList:
                button = ObjectFactory.button(Buttons.Custom, 
                                              buttonText,
                                              command)
                buttons.append(button)
            return buttons

        buttons = createCustomButtons()
        utterance = ObjectFactory.utterance("Welche Station willst du hören?")
        self.makeView([utterance] + buttons)
        self.completeRequest()
Exemplo n.º 10
0
    def testButtons(self, text):
        """This is an example of a speech rule which triggers when
        the user says "Test custom buttons".

        This example demonstrates how to display buttons to the user
        which execute custom commands when the button is pressed. This
        plugin is able to respond to the custom commands.

        * text -- The text spoken by the user

        """
        # Create the custom command buttons
        buttons = self.__createCustomButtons()

        # Create an utterance to go along with the buttons
        utterance = ObjectFactory.utterance("Please press a button")

        # Now create a view which displays the utterance and the buttons
        self.makeView([utterance] + buttons)

        self.completeRequest()
Exemplo n.º 11
0
    def testButtons(self, text):
        '''This is an example of a speech rule which triggers when
        the user says "Test custom buttons".

        This example demonstrates how to display buttons to the user
        which execute custom commands when the button is pressed. This
        plugin is able to respond to the custom commands.

        * text -- The text spoken by the user

        '''
        # Create the custom command buttons
        buttons = self.__createCustomButtons()

        # Create an utterance to go along with the buttons
        utterance = ObjectFactory.utterance("Please press a button")

        # Now create a view which displays the utterance and the buttons
        self.makeView([utterance] + buttons)

        self.completeRequest()