MainController.py 1.4 KB

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