浏览代码

Merge branch 'dev' into neurons-OpenWeatherMap

monf 8 年之前
父节点
当前提交
67bdaaebb4
共有 5 个文件被更改,包括 12 次插入16 次删除
  1. 1 1
      core/OrderAnalyser.py
  2. 1 1
      kalliope.py
  3. 二进制
      trigger/snowboy/_snowboydetect.so
  4. 7 11
      trigger/snowboy/snowboydecoder.py
  5. 3 3
      trigger/snowboy/snowboydetect.py

+ 1 - 1
core/OrderAnalyser.py

@@ -49,7 +49,7 @@ class OrderAnalyser:
 
                         for neuron in synapse.neurons:
                             if isinstance(neuron.parameters, dict):
-                                print neuron.parameters
+                                # print neuron.parameters
                                 if "args" in neuron.parameters:
                                     logger.debug("The neuron wait for parameter")
                                     # check that the user added parameters to his order

+ 1 - 1
kalliope.py

@@ -21,7 +21,7 @@ def signal_handler(signal, frame):
     Utils.print_info("Ctrl+C pressed. Killing Kalliope")
     sys.exit(0)
 
-ACTION_LIST = ["start", "gui", "load-events"]
+ACTION_LIST = ["start", "gui"]
 
 
 def main():

二进制
trigger/snowboy/_snowboydetect.so


+ 7 - 11
trigger/snowboy/snowboydecoder.py

@@ -1,14 +1,12 @@
 #!/usr/bin/env python
 
 import collections
-import logging
-import os
-import time
-import wave
-
 import pyaudio
-
 import snowboydetect
+import time
+import wave
+import os
+import logging
 
 logging.basicConfig()
 logger = logging.getLogger("snowboy")
@@ -31,7 +29,7 @@ class RingBuffer(object):
 
     def get(self):
         """Retrieves data from the beginning of buffer and clears it"""
-        tmp = ''.join(self._buf)
+        tmp = bytes(bytearray(self._buf))
         self._buf.clear()
         return tmp
 
@@ -90,7 +88,7 @@ class HotwordDetector(object):
         model_str = ",".join(decoder_model)
 
         self.detector = snowboydetect.SnowboyDetect(
-            resource_filename=resource, model_str=model_str)
+            resource_filename=resource.encode(), model_str=model_str.encode())
         self.detector.SetAudioGain(audio_gain)
         self.num_hotwords = self.detector.NumHotwords()
 
@@ -102,7 +100,7 @@ class HotwordDetector(object):
                 "(%d) does not match" % (self.num_hotwords, len(sensitivity))
         sensitivity_str = ",".join([str(t) for t in sensitivity])
         if len(sensitivity) != 0:
-            self.detector.SetSensitivity(sensitivity_str);
+            self.detector.SetSensitivity(sensitivity_str.encode())
 
         self.ring_buffer = RingBuffer(
             self.detector.NumChannels() * self.detector.SampleRate() * 5)
@@ -164,8 +162,6 @@ class HotwordDetector(object):
             ans = self.detector.RunDetection(data)
             if ans == -1:
                 logger.warning("Error initializing streams or reading audio data")
-            elif ans == -2:
-                logger.debug("Silence")
             elif ans > 0:
                 message = "Keyword " + str(ans) + " detected at time: "
                 message += time.strftime("%Y-%m-%d %H:%M:%S",

+ 3 - 3
trigger/snowboy/snowboydetect.py

@@ -1,5 +1,5 @@
 # This file was automatically generated by SWIG (http://www.swig.org).
-# Version 3.0.7
+# Version 3.0.8
 #
 # Do not make changes to this file unless you know what you are doing--modify
 # the SWIG interface file instead.
@@ -77,7 +77,7 @@ def _swig_getattr(self, class_type, name):
 def _swig_repr(self):
     try:
         strthis = "proxy of " + self.this.__repr__()
-    except:
+    except Exception:
         strthis = ""
     return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
 
@@ -101,7 +101,7 @@ class SnowboyDetect(_object):
         this = _snowboydetect.new_SnowboyDetect(resource_filename, model_str)
         try:
             self.this.append(this)
-        except:
+        except Exception:
             self.this = this
 
     def Reset(self):