Fix invalid chunk size in PreciseRunner and fix importing from db

pull/10/head
Matthew D. Scholefield 2018-03-21 03:44:39 -05:00
parent 0fe1bceede
commit dcad96fc4e
4 changed files with 8 additions and 4 deletions

View File

@ -14,7 +14,7 @@
import json
from argparse import ArgumentParser
from hashlib import md5
from os.path import join, isfile
from os.path import join, isfile, dirname
from typing import *
import numpy as np
@ -64,7 +64,7 @@ class TrainData:
raise RuntimeError('Database file does not exist: ' + db_file)
train_groups = {}
train_group_file = db_file.replace('db', '') + 'groups.json'
train_group_file = join(dirname(db_folder), db_file.replace('.txt', '') + '.groups.json')
if isfile(train_group_file):
with open(train_group_file) as f:
train_groups = json.load(f)

3
runner/README.md Normal file
View File

@ -0,0 +1,3 @@
# Precise Wrapper
A simple to use

View File

@ -20,6 +20,7 @@ from threading import Event
def main():
parser = ArgumentParser('Implementation demo of precise-engine')
parser.add_argument('engine', help='Location of binary engine file')
parser.add_argument('model')
args = parser.parse_args()
@ -29,7 +30,7 @@ def main():
def on_activation():
Popen(['aplay', '-q', 'data/activate.wav'])
engine = PreciseEngine('./precise/engine.py', args.model)
engine = PreciseEngine(args.engine, args.model)
PreciseRunner(engine, on_prediction=on_prediction, on_activation=on_activation,
trigger_level=0).start()
Event().wait() # Wait forever

View File

@ -163,7 +163,7 @@ class PreciseRunner:
"""Continuously check Precise process output"""
activation = 0
while self.running:
chunk = self.stream.read(self.chunk_size)
chunk = self.stream.read(self.chunk_size // 2)
prob = self.engine.get_prediction(chunk)
self.on_prediction(prob)