SettingEditor.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import logging
  2. from kalliope.core.Utils import Utils
  3. from kalliope.core.HookManager import HookManager
  4. from kalliope.core.ConfigurationManager import SettingLoader
  5. logging.basicConfig()
  6. logger = logging.getLogger("kalliope")
  7. class SettingEditor(object):
  8. """This class provides methods/functions to update properties from the Settings"""
  9. @staticmethod
  10. def set_mute_status(mute=False):
  11. """
  12. Define is the mute status
  13. :param mute: Boolean. If false, Kalliope is voice is stopped
  14. """
  15. logger.debug("[SettingEditor] mute. Switch trigger process to mute : %s" % mute)
  16. settings = SettingLoader().settings
  17. if mute:
  18. Utils.print_info("Kalliope now muted, voice has been stopped.")
  19. HookManager.on_mute()
  20. else:
  21. Utils.print_info("Kalliope now speaking.")
  22. HookManager.on_unmute()
  23. settings.options["mute"] = mute
  24. @staticmethod
  25. def set_deaf_status(trigger_instance, deaf=False):
  26. """
  27. Define is the trigger is listening or not.
  28. :param trigger_instance: the trigger instance coming from the order. It will be paused or unpaused.
  29. :param deaf: Boolean. If true, kalliope is trigger is paused
  30. """
  31. logger.debug("[MainController] deaf . Switch trigger process to deaf : %s" % deaf)
  32. settings = SettingLoader().settings
  33. if deaf:
  34. trigger_instance.pause()
  35. Utils.print_info("Kalliope now deaf, trigger has been paused")
  36. HookManager.on_deaf()
  37. else:
  38. trigger_instance.unpause()
  39. Utils.print_info("Kalliope now listening for trigger detection")
  40. HookManager.on_undeaf()
  41. settings.options["deaf"] = deaf