浏览代码

dynamic load of the snowboy lib according to the current arch of the machine (x86_64 or arm)

nico 8 年之前
父节点
当前提交
6af2d356e4

+ 7 - 0
Docs/microphone_rpi.md

@@ -0,0 +1,7 @@
+
+
+pi@alarmpi:~ $ cat /proc/asound/cards
+ 0 [ALSA           ]: bcm2835 - bcm2835 ALSA
+                      bcm2835 ALSA
+ 1 [Headset        ]: USB-Audio - Logitech USB Headset
+                      Logitech Logitech USB Headset at usb-3f980000.usb-1.3, full speed

+ 4 - 1
core/Models/Settings.py

@@ -1,4 +1,5 @@
 from core.Models import Singleton
+import platform
 
 
 @Singleton
@@ -19,7 +20,8 @@ class Settings(object):
                  random_wake_up_sounds=None,
                  triggers=None,
                  rest_api=None,
-                 cache_path=None):
+                 cache_path=None,
+                 machine=None):
 
         self.default_tts_name = default_tts_name
         self.default_stt_name = default_stt_name
@@ -32,3 +34,4 @@ class Settings(object):
         self.rest_api = rest_api
         self.cache_path = cache_path
         self.is_loaded = False
+        self.machine = platform.machine()   # can be x86_64 or armv7l

二进制
trigger/snowboy/armv7l/_snowboydetect.so


+ 6 - 4
trigger/snowboy/snowboydetect.py

@@ -3,19 +3,21 @@
 #
 # Do not make changes to this file unless you know what you are doing--modify
 # the SWIG interface file instead.
+from core.ConfigurationManager import SettingLoader
+from sys import version_info
 
+settings = SettingLoader.get_settings()
+module_file_path = "%s/_snowboydetect" % settings.machine
 
 
-
-
-from sys import version_info
 if version_info >= (2, 6, 0):
     def swig_import_helper():
         from os.path import dirname
         import imp
         fp = None
         try:
-            fp, pathname, description = imp.find_module('_snowboydetect', [dirname(__file__)])
+            fp, pathname, description = imp.find_module(module_file_path, [dirname(__file__)])
+            print pathname
         except ImportError:
             import _snowboydetect
             return _snowboydetect

+ 0 - 0
trigger/snowboy/_snowboydetect.so → trigger/snowboy/x86_64/_snowboydetect.so