Browse Source

restart the trigger even if the STT engine return nothing

nico 8 years ago
parent
commit
4d69724065
6 changed files with 25 additions and 3 deletions
  1. 5 3
      core/MainController.py
  2. 4 0
      stt/apiai/Apiai.py
  3. 4 0
      stt/bing/Bing.py
  4. 4 0
      stt/google/Google.py
  5. 4 0
      stt/houndify/Houndify.py
  6. 4 0
      stt/wit/Wit.py

+ 5 - 3
core/MainController.py

@@ -58,12 +58,14 @@ class MainController:
 
     def analyse_order(self, order):
         """
-        Receive an order, try to retreive it in the brain.yml to launch to attached plugins
+        Receive an order, try to retrieve it in the brain.yml to launch to attached plugins
         :param order: the sentence received
         :type order: str
         """
-        order_analyser = OrderAnalyser(order, main_controller=self, brain=self.brain)
-        order_analyser.start()
+        if order is not None:   # maybe we have received a null audio from STT engine
+            order_analyser = OrderAnalyser(order, main_controller=self, brain=self.brain)
+            order_analyser.start()
+
         # restart the trigger when the order analyser has finish his job
         Utils.print_info("Waiting for trigger detection")
         self.trigger_instance.unpause()

+ 4 - 0
stt/apiai/Apiai.py

@@ -38,8 +38,12 @@ class Apiai(OrderListener):
 
         except sr.UnknownValueError as e:
             Utils.print_warning("Apiai Speech Recognition could not understand audio; {0}".format(e))
+            # callback anyway, we need to listen again for a new order
+            self._analyse_audio(audio=None)
         except sr.RequestError as e:
             Utils.print_danger("Could not request results from Apiai Speech Recognition service; {0}".format(e))
+            # callback anyway, we need to listen again for a new order
+            self._analyse_audio(audio=None)
 
     def _analyse_audio(self, audio):
         """

+ 4 - 0
stt/bing/Bing.py

@@ -37,8 +37,12 @@ class Bing(OrderListener):
 
         except sr.UnknownValueError:
             Utils.print_warning("Bing Speech Recognition could not understand audio")
+            # callback anyway, we need to listen again for a new order
+            self._analyse_audio(audio=None)
         except sr.RequestError as e:
             Utils.print_danger("Could not request results from Bing Speech Recognition service; {0}".format(e))
+            # callback anyway, we need to listen again for a new order
+            self._analyse_audio(audio=None)
 
     def _analyse_audio(self, audio):
         """

+ 4 - 0
stt/google/Google.py

@@ -40,8 +40,12 @@ class Google(OrderListener):
 
         except sr.UnknownValueError:
             Utils.print_warning("Google Speech Recognition could not understand audio")
+            # callback anyway, we need to listen again for a new order
+            self._analyse_audio(audio=None)
         except sr.RequestError as e:
             Utils.print_danger("Could not request results from Google Speech Recognition service; {0}".format(e))
+            # callback anyway, we need to listen again for a new order
+            self._analyse_audio(audio=None)
 
     def _analyse_audio(self, audio):
         """

+ 4 - 0
stt/houndify/Houndify.py

@@ -38,8 +38,12 @@ class Houndify(OrderListener):
 
         except sr.UnknownValueError:
             Utils.print_warning("Houndify Speech Recognition could not understand audio")
+            # callback anyway, we need to listen again for a new order
+            self._analyse_audio(audio=None)
         except sr.RequestError as e:
             Utils.print_danger("Could not request results from Houndify Speech Recognition service; {0}".format(e))
+            # callback anyway, we need to listen again for a new order
+            self._analyse_audio(audio=None)
 
     def _analyse_audio(self, audio):
         """

+ 4 - 0
stt/wit/Wit.py

@@ -35,8 +35,12 @@ class Wit(OrderListener):
 
         except sr.UnknownValueError:
             Utils.print_warning("Wit.ai Speech Recognition could not understand audio")
+            # callback anyway, we need to listen again for a new order
+            self._analyse_audio(audio=None)
         except sr.RequestError as e:
             Utils.print_danger("Could not request results from Wit.ai Speech Recognition service; {0}".format(e))
+            # callback anyway, we need to listen again for a new order
+            self._analyse_audio(audio=None)
 
     def _analyse_audio(self, audio):
         """