MainController.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. from core.JarvisTrigger import JarvisTrigger
  2. from core.OrderAnalyser import OrderAnalyser
  3. from core.OrderListener import OrderListener
  4. from core.ConfigurationManager.ConfigurationManager import ConfigurationManager
  5. from neurons import Say
  6. class MainController:
  7. def __init__(self):
  8. # Manage Global Configuration
  9. self.conf = ConfigurationManager()
  10. # create an order listener object
  11. self.order_listener = OrderListener(self)
  12. # Wait that the jarvis trigger is pronounced by the user
  13. self.jarvis_triger = JarvisTrigger(self)
  14. def get_order_listenner(self):
  15. return self.order_listener
  16. def start(self):
  17. self.jarvis_triger.start()
  18. def pause_jarvis_trigger(self):
  19. """
  20. The hotwork to wake up jarvis has been detected, we pause the snowboy process
  21. :return:
  22. """
  23. self.jarvis_triger.pause()
  24. def unpause_jarvis_trigger(self):
  25. self.jarvis_triger.unpause()
  26. def hotword_detected(self):
  27. """
  28. # we have detected the hotword, we can now pause the Jarvis Trigger for a while
  29. # The user can speak out loud his order during this time.
  30. :return:
  31. """
  32. # pause the snowboy process
  33. self.pause_jarvis_trigger()
  34. print "Start listening for order"
  35. Say("oui monsieur?")
  36. self.order_listener.start()
  37. def analyse_order(self, order):
  38. """
  39. Receive an order, try to retreive it in the brain.yml to launch to attached plugins
  40. :return:
  41. """
  42. order_analyser = OrderAnalyser(order, main_controller=self)
  43. order_analyser.start()