コード例 #1
0
    def _get_settings(self):
        """
        Class Methods which loads default or the provided YAML file and return a Settings Object

        :return: The loaded Settings
        :rtype: Settings

        :Example:

            settings = SettingLoader.get_settings(file_path="/var/tmp/settings.yml")

        .. seealso:: Settings
        .. warnings:: Class Method
        """

        # create a new setting
        setting_object = Settings()

        # Get the setting parameters
        settings = self._get_yaml_config()
        default_stt_name = self._get_default_speech_to_text(settings)
        default_tts_name = self._get_default_text_to_speech(settings)
        default_trigger_name = self._get_default_trigger(settings)
        default_player_name = self._get_default_player(settings)
        stts = self._get_stts(settings)
        ttss = self._get_ttss(settings)
        triggers = self._get_triggers(settings)
        players = self._get_players(settings)
        rest_api = self._get_rest_api(settings)
        cache_path = self._get_cache_path(settings)
        resources = self._get_resources(settings)
        variables = self._get_variables(settings)
        options = self._get_options(settings)
        hooks = self._get_hooks(settings)
        tracker_anonymous_usage_stats_id = self._get_anonymous_usage_stats(
            settings)

        # Load the setting singleton with the parameters
        setting_object.default_tts_name = default_tts_name
        setting_object.default_stt_name = default_stt_name
        setting_object.default_trigger_name = default_trigger_name
        setting_object.default_player_name = default_player_name
        setting_object.stts = stts
        setting_object.ttss = ttss
        setting_object.triggers = triggers
        setting_object.players = players
        setting_object.rest_api = rest_api
        setting_object.cache_path = cache_path
        setting_object.resources = resources
        setting_object.variables = variables
        setting_object.options = options
        setting_object.hooks = hooks
        setting_object.tracker_anonymous_usage_stats_id = tracker_anonymous_usage_stats_id

        return setting_object
コード例 #2
0
    def test_get_settings(self):
        settings_object = Settings()
        settings_object.default_tts_name = "pico2wave"
        settings_object.default_stt_name = "google"
        settings_object.default_trigger_name = "snowboy"
        settings_object.default_player_name = "mplayer"
        tts1 = Tts(name="pico2wave", parameters={'cache': True, 'language': 'fr-FR'})
        tts2 = Tts(name="googletts", parameters={'language': 'fr', 'cache': True})
        settings_object.ttss = [tts1, tts2]
        stt = Stt(name="google", parameters={'language': 'fr-FR'})
        settings_object.stts = [stt]
        trigger1 = Trigger(name="snowboy",
                           parameters={'pmdl_file': 'trigger/snowboy/resources/kalliope-FR-6samples.pmdl'})
        settings_object.triggers = [trigger1]
        player1 = Player(name="mplayer", parameters={})
        player2 = Player(name="pyalsaaudio", parameters={"device": "default"})
        settings_object.players = [player1, player2]
        settings_object.rest_api = RestAPI(password_protected=True, active=True,
                                           login="******", password="******", port=5000,
                                           allowed_cors_origin=False)
        settings_object.cache_path = '/tmp/kalliope_tts_cache'
        resources = Resources(neuron_folder="/tmp/kalliope/tests/kalliope_resources_dir/neurons",
                              stt_folder="/tmp/kalliope/tests/kalliope_resources_dir/stt",
                              tts_folder="/tmp/kalliope/tests/kalliope_resources_dir/tts",
                              trigger_folder="/tmp/kalliope/tests/kalliope_resources_dir/trigger")
        settings_object.resources = resources
        settings_object.variables = {
            "author": "Lamonf",
            "test_number": 60,
            "test": "kalliope"
        }
        settings_object.options = Options(energy_threshold=3000, deaf=True, mute=False)
        settings_object.machine = platform.machine()
        settings_object.hooks = {'on_waiting_for_trigger': 'test',
                                 'on_stop_listening': None,
                                 'on_start_listening': None,
                                 'on_order_found': None,
                                 'on_start': ['on-start-synapse', 'bring-led-on'],
                                 'on_undeaf': [],
                                 'on_triggered': ['on-triggered-synapse'],
                                 'on_deaf': [],
                                 'on_mute': [],
                                 'on_unmute': [],
                                 'on_order_not_found': [
                                     'order-not-found-synapse'],
                                 'on_processed_synapses': None,
                                 'on_start_speaking': None,
                                 'on_stop_speaking': None,
                                 }

        sl = SettingLoader(file_path=self.settings_file_to_test)

        self.assertEqual(settings_object, sl.settings)
コード例 #3
0
ファイル: SettingLoader.py プロジェクト: igorstarki/kalliope
    def _get_settings(self):
        """
        Class Methods which loads default or the provided YAML file and return a Settings Object

        :return: The loaded Settings
        :rtype: Settings

        :Example:

            settings = SettingLoader.get_settings(file_path="/var/tmp/settings.yml")

        .. seealso:: Settings
        .. warnings:: Class Method
        """

        # create a new setting
        setting_object = Settings()

        # Get the setting parameters
        settings = self._get_yaml_config()
        default_stt_name = self._get_default_speech_to_text(settings)
        default_tts_name = self._get_default_text_to_speech(settings)
        default_trigger_name = self._get_default_trigger(settings)
        default_player_name = self._get_default_player(settings)
        stts = self._get_stts(settings)
        ttss = self._get_ttss(settings)
        triggers = self._get_triggers(settings)
        players = self._get_players(settings)
        rest_api = self._get_rest_api(settings)
        cache_path = self._get_cache_path(settings)
        resources = self._get_resources(settings)
        variables = self._get_variables(settings)
        options = self._get_options(settings)
        hooks = self._get_hooks(settings)

        # Load the setting singleton with the parameters
        setting_object.default_tts_name = default_tts_name
        setting_object.default_stt_name = default_stt_name
        setting_object.default_trigger_name = default_trigger_name
        setting_object.default_player_name = default_player_name
        setting_object.stts = stts
        setting_object.ttss = ttss
        setting_object.triggers = triggers
        setting_object.players = players
        setting_object.rest_api = rest_api
        setting_object.cache_path = cache_path
        setting_object.resources = resources
        setting_object.variables = variables
        setting_object.options = options
        setting_object.hooks = hooks

        return setting_object
コード例 #4
0
    def test_get_settings(self):
        settings_object = Settings()
        settings_object.default_tts_name = "pico2wave"
        settings_object.default_stt_name = "google"
        settings_object.default_trigger_name = "snowboy"
        settings_object.default_player_name = "mplayer"
        tts1 = Tts(name="pico2wave",
                   parameters={
                       'cache': True,
                       'language': 'fr-FR'
                   })
        tts2 = Tts(name="googletts",
                   parameters={
                       'language': 'fr',
                       'cache': True
                   })
        settings_object.ttss = [tts1, tts2]
        stt = Stt(name="google", parameters={'language': 'fr-FR'})
        settings_object.stts = [stt]
        trigger1 = Trigger(
            name="snowboy",
            parameters={
                'pmdl_file':
                'trigger/snowboy/resources/kalliope-FR-6samples.pmdl'
            })
        settings_object.triggers = [trigger1]
        player1 = Player(name="mplayer", parameters={})
        player2 = Player(name="pyalsaaudio", parameters={"device": "default"})
        settings_object.players = [player1, player2]
        settings_object.rest_api = RestAPI(password_protected=True,
                                           active=True,
                                           login="******",
                                           password="******",
                                           port=5000,
                                           allowed_cors_origin=False)
        settings_object.cache_path = '/tmp/kalliope_tts_cache'
        resources = Resources(
            neuron_folder="/tmp/kalliope/tests/kalliope_resources_dir/neurons",
            stt_folder="/tmp/kalliope/tests/kalliope_resources_dir/stt",
            tts_folder="/tmp/kalliope/tests/kalliope_resources_dir/tts",
            trigger_folder="/tmp/kalliope/tests/kalliope_resources_dir/trigger"
        )
        settings_object.resources = resources
        settings_object.variables = {
            "author": "Lamonf",
            "test_number": 60,
            "test": "kalliope"
        }
        settings_object.options = Options(energy_threshold=3000,
                                          deaf=True,
                                          mute=False)
        settings_object.machine = platform.machine()
        settings_object.hooks = {
            'on_waiting_for_trigger': 'test',
            'on_stop_listening': None,
            'on_start_listening': None,
            'on_order_found': None,
            'on_start': ['on-start-synapse', 'bring-led-on'],
            'on_undeaf': [],
            'on_triggered': ['on-triggered-synapse'],
            'on_deaf': [],
            'on_mute': [],
            'on_unmute': [],
            'on_order_not_found': ['order-not-found-synapse'],
            'on_processed_synapses': None,
            'on_start_speaking': None,
            'on_stop_speaking': None,
        }

        sl = SettingLoader(file_path=self.settings_file_to_test)

        self.assertEqual(settings_object, sl.settings)