Пример #1
0
    def test_say(self):
        # single message
        parameters = {"message": "test message"}
        with mock.patch(self.pico_say_method_path) as mock_tts:
            Say(**parameters)
            mock_tts.assert_called_once_with("test message")

        # template
        template_path = "test_say_neuron_template.j2"
        current_path = os.getcwd()
        if "tests" not in current_path:
            template_path = "kalliope/neurons/say/tests/test_say_neuron_template.j2"

        parameters = {"file_template": template_path}
        with mock.patch(self.pico_say_method_path) as mock_tts:
            Say(**parameters)
            mock_tts.assert_called_once_with("hello sir")
Пример #2
0
    def _run_tts_test(tts_name, sentence_to_test):
        """
        Call the TTS
        :param tts_name: Name of the TTS module to launch
        :param sentence_to_test: String text to send to the TTS engine
        """
        sentence_to_test = sentence_to_test.encode('utf-8')
        tts_name = tts_name.encode('utf-8')

        Say(message=sentence_to_test, tts=tts_name)
Пример #3
0
    def play_wake_up_answer_thread(self):
        """
        Play a sound or make Kalliope say something to notify the user that she has been awaken and now
        waiting for order
        """
        logger.debug("Entering state: %s" % self.state)
        # if random wake answer sentence are present, we play this
        if self.settings.random_wake_up_answers is not None:
            Say(message=self.settings.random_wake_up_answers)
        else:
            random_sound_to_play = self._get_random_sound(self.settings.random_wake_up_sounds)
            Mplayer.play(random_sound_to_play)

        self.next_state()
Пример #4
0
 def play_ready_sound_process(self):
     """
     Play a sound when Kalliope is ready to be awaken at the first start
     """
     logger.debug("Entering state: %s" % self.state)
     if (not self.on_ready_notification_played_once and self.settings.play_on_ready_notification == "once") or \
             self.settings.play_on_ready_notification == "always":
         # we remember that we played the notification one time
         self.on_ready_notification_played_once = True
         # here we tell the user that we are listening
         if self.settings.on_ready_answers is not None:
             Say(message=self.settings.on_ready_answers)
         elif self.settings.on_ready_sounds is not None:
             random_sound_to_play = self._get_random_sound(self.settings.on_ready_sounds)
             Mplayer.play(random_sound_to_play)
     self.next_state()
Пример #5
0
 def callback(self):
     """
     we have detected the hotword, we can now pause the Trigger for a while
     The user can speak out loud his order during this time.
     """
     # pause the trigger process
     self.trigger_instance.pause()
     # start listening for an order
     self.order_listener.start()
     # if random wake answer sentence are present, we play this
     if self.settings.random_wake_up_answers is not None:
         Say(message=self.settings.random_wake_up_answers)
     else:
         random_sound_to_play = self._get_random_sound(
             self.settings.random_wake_up_sounds)
         Mplayer.play(random_sound_to_play)
Пример #6
0
 def run_test(parameters_to_test):
     with self.assertRaises(MissingParameterException):
         Say(**parameters_to_test)