Browse Source

centralize call via main controller

Nicolas Marcq 8 years ago
parent
commit
a56e7597fd
3 changed files with 25 additions and 17 deletions
  1. 1 2
      core/JarvisTrigger.py
  2. 14 1
      core/MainController.py
  3. 10 14
      core/OrderListener.py

+ 1 - 2
core/JarvisTrigger.py

@@ -1,4 +1,3 @@
-from core.OrderListener import OrderListener
 from stt.snowboy import snowboydecoder
 
 
@@ -34,7 +33,7 @@ class JarvisTrigger:
         detector = snowboydecoder.HotwordDetector(self.model, sensitivity=0.4)
 
         # start snowboy loop
-        detector.start(detected_callback=self.main_controller.get_order_listenner().hotword_detected,
+        detector.start(detected_callback=self.main_controller.hotword_detected,
                        interrupt_check=self.interrupt_callback,
                        sleep_time=0.03)
 

+ 14 - 1
core/MainController.py

@@ -1,5 +1,6 @@
 from core.JarvisTrigger import JarvisTrigger
 from core.OrderListener import OrderListener
+from neurons import Say
 
 
 class MainController:
@@ -20,4 +21,16 @@ class MainController:
         The hotwork to wake up jarvis has been detected, we pause the snowboy process
         :return:
         """
-        pass
+        pass
+
+    def hotword_detected(self):
+        """
+        # we have detected the hotword, we can now pause the Jarvis Trigger for a while
+        # The user can speak out loud his order during this time.
+        :return:
+        """
+        # pause the snowboy process
+        self.pause_jarvis_trigger()
+        print "Start listening for order"
+        Say("oui monsieur?")
+        self.order_listener.start()

+ 10 - 14
core/OrderListener.py

@@ -1,23 +1,19 @@
-from neurons import Say
-
 
 class OrderListener:
-    """
-    This class is called after we catch the hotword that have woke up JARVIS.
-    We now wait for an order spoken out loud by the user, translate the order into a text and run the action
-     attached to this order from settings
-    """
+
     def __init__(self, main_controller):
         """
-
+        This class is called after we catch the hotword that have woke up JARVIS.
+        We now wait for an order spoken out loud by the user, translate the order into a text and run the action
+         attached to this order from settings
         :param main_controller:
         :type main_controller: MainController
         """
         self.main_controller = main_controller
 
-    def hotword_detected(self):
-        # we have detected the hotword, we can now pause the Jarvis Trigger for a while
-        # The user can speak out loud his order during this time.
-        self.main_controller.pause_jarvis_trigger()
-        print "Start listening for order"
-        Say("oui monsieur?")
+    def start(self):
+        """
+        Start recording the microphone
+        :return:
+        """
+        pass