diff options
| -rw-r--r-- | client/app_utils.py (renamed from client/modules/app_utils.py) | 0 | ||||
| -rw-r--r-- | client/brain.py | 6 | ||||
| -rw-r--r-- | client/mic.py | 7 | ||||
| -rw-r--r-- | client/test.py | 2 | ||||
| -rwxr-xr-x | jasper.py | 6 |
5 files changed, 15 insertions, 6 deletions
diff --git a/client/modules/app_utils.py b/client/app_utils.py index cea6881..cea6881 100644 --- a/client/modules/app_utils.py +++ b/client/app_utils.py diff --git a/client/brain.py b/client/brain.py index 007b7fe..6daa366 100644 --- a/client/brain.py +++ b/client/brain.py @@ -35,11 +35,11 @@ class Brain(object): logger = logging.getLogger(__name__) module_locations = [jasperpath.PLUGIN_PATH] logger.debug("Looking for modules in: %s", ', '.join(["'%s'" % location for location in module_locations])) - module_names = [name for loader, name, ispkg in pkgutil.walk_packages(module_locations, prefix='modules.')] modules = [] - for name in module_names: + for finder, name, ispkg in pkgutil.walk_packages(module_locations): try: - mod = importlib.import_module(name) + loader = finder.find_module(name) + mod = loader.load_module(name) except: logger.warning("Skipped module '%s' due to an error.", name, exc_info=True) else: diff --git a/client/mic.py b/client/mic.py index 2e8d603..7956b1d 100644 --- a/client/mic.py +++ b/client/mic.py @@ -70,6 +70,10 @@ class Mic: lastN.append(self.getScore(data)) average = sum(lastN) / len(lastN) + stream.stop_stream() + stream.close() + audio.terminate() + # this will be the benchmark to cause a disturbance over! THRESHOLD = average * THRESHOLD_MULTIPLIER @@ -139,6 +143,9 @@ class Mic: # no use continuing if no flag raised if not didDetect: print "No disturbance detected" + stream.stop_stream() + stream.close() + audio.terminate() return (None, None) # cutoff any recording before this disturbance was detected diff --git a/client/test.py b/client/test.py index 9c99688..23dd619 100644 --- a/client/test.py +++ b/client/test.py @@ -224,7 +224,7 @@ class TestBrain(unittest.TestCase): def testPriority(self): """Does Brain correctly send query to higher-priority module?""" my_brain = TestBrain._emptyBrain() - hn_module = 'modules.HN' + hn_module = 'HN' hn = filter(lambda m: m.__name__ == hn_module, my_brain.modules)[0] with patch.object(hn, 'handle') as mocked_handle: @@ -10,6 +10,10 @@ import argparse from client.diagnose import Diagnostics from client import vocabcompiler, tts, stt, jasperpath + +# Add jasperpath.LIB_PATH to sys.path +sys.path.append(jasperpath.LIB_PATH) + from client.conversation import Conversation parser = argparse.ArgumentParser(description='Jasper Voice Control Center') @@ -25,8 +29,6 @@ else: # Change CWD to jasperpath.LIB_PATH os.chdir(jasperpath.LIB_PATH) -# Add jasperpath.LIB_PATH to sys.path -sys.path.append(jasperpath.LIB_PATH) class Jasper(object): def __init__(self): |
