MainController.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. pass
  21. def hotword_detected(self):
  22. """
  23. # we have detected the hotword, we can now pause the Jarvis Trigger for a while
  24. # The user can speak out loud his order during this time.
  25. :return:
  26. """
  27. # pause the snowboy process
  28. self.pause_jarvis_trigger()
  29. print "Start listening for order"
  30. Say("oui monsieur?")
  31. self.order_listener.start()
  32. def analyse_order(self, order):
  33. """
  34. Receive an order, try to retreive it in the brain.yml to launch to attached plugins
  35. :return:
  36. """
  37. order_analyser = OrderAnalyser(order)
  38. order_analyser.start()