Exemple #1
0
    def test_load_stt_plugin(self):

        # Test getting default stt
        ol = OrderListener()

        stt1 = Stt(name="default-stt", parameters=dict())

        stt2 = Stt(name="second-stt", parameters=dict())

        stt3 = Stt(name="third-stt", parameters=dict())

        resources = Resources(stt_folder="/tmp")
        ol.settings = mock.MagicMock(default_stt_name="default-stt",
                                     stts=[stt1, stt2, stt3],
                                     resources=resources)

        callback = mock.MagicMock()

        ol.callback = callback

        with mock.patch("kalliope.core.Utils.get_dynamic_class_instantiation"
                        ) as mock_get_dynamic_class_instantiation:
            mock_get_dynamic_class_instantiation.return_value = 'class_instance'
            self.assertEqual(ol.load_stt_plugin(), "class_instance",
                             "Fail getting the proper value")

            mock_get_dynamic_class_instantiation.assert_called_once_with(
                package_name="stt",
                module_name="Default-stt",
                parameters={
                    'callback': callback,
                    'audio_file_path': None
                },
                resources_dir="/tmp")
    def test_load_stt_plugin(self):

        # Test getting default stt
        ol = OrderListener()

        stt1 = Stt(name="default-stt",
                   parameters=dict())

        stt2 = Stt(name="second-stt",
                   parameters=dict())

        stt3 = Stt(name="third-stt",
                   parameters=dict())

        resources = Resources(stt_folder="/tmp")
        ol.settings = mock.MagicMock(default_stt_name="default-stt",
                                     stts=[stt1,stt2,stt3],
                                     resources=resources)

        callback = mock.MagicMock()

        ol.callback = callback

        with mock.patch("kalliope.core.Utils.get_dynamic_class_instantiation") as mock_get_dynamic_class_instantiation:
            mock_get_dynamic_class_instantiation.return_value = 'class_instance'
            self.assertEqual(ol.load_stt_plugin(),
                             "class_instance",
                             "Fail getting the proper value")

            mock_get_dynamic_class_instantiation.assert_called_once_with(package_name= "stt",
                                                                         module_name= "Default-stt",
                                                                         parameters={'callback' : callback},
                                                                         resources_dir= "/tmp")
Exemple #3
0
 def get_audio_from_stt(callback):
     """
     Call the default STT to get an audio sample and return it into the callback method
     :param callback: A callback function
     """
     # call the order listener
     oa = OrderListener(callback=callback)
     oa.start()
Exemple #4
0
 def get_audio_from_stt(callback):
     """
     Call the default STT to get an audio sample and return it into the callback method
     :param callback: A callback function
     """
     # call the order listener
     ol = OrderListener(callback=callback)
     ol.start()
     ol.join()
     # wait that the STT engine has finish his job (or the neurotransmitter neuron will be killed)
     if ol.stt_instance is not None:
         ol.stt_instance.join()
Exemple #5
0
    def show_stt_test_menu(self):
        """
        Show the list of available STT.
        Clicking on a STT will load the engine to catch the user audio and return a text
        """
        # we get STT from settings
        stt_list = self.settings.stts
        logger.debug("Loaded stt list: %s" % str(stt_list))
        choices = self._get_choices_tuple_from_list(stt_list)

        code, tag = self.d.menu("Select the STT to test:", choices=choices)

        # go back to the main menu if we choose "cancel"
        if code == self.d.CANCEL:
            self.show_main_menu()

        # if ok, call the target TTS engine and catch audio
        if code == self.d.OK:
            self.d.infobox("Please talk now")
            # the callback funtion will print the translated audio into text on the screen
            order_listener = OrderListener(callback=self.callback_stt,
                                           stt=str(tag))
            order_listener.load_stt_plugin()
Exemple #6
0
 def get_audio_from_stt(callback):
     """
     Call the default STT to get an audio sample and return it into the callback method
     :param callback: A callback function
     """
     # call the order listener
     ol = OrderListener(callback=callback)
     ol.start()
     ol.join()
     # wait that the STT engine has finish his job (or the neurotransmitter neuron will be killed)
     if ol.stt_instance is not None:
         ol.stt_instance.join()