mycroft-precise
mycroft-precise copied to clipboard
Combining PreciseRunner and PreciseEngine
How come the PreciseRunner
and PreciseEngine
classes aren't combined into a single class like so?
precise = Precise(
binary = 'precise-engine/precise-engine',
model = 'model.pb',
on_activation = lambda: print('Detected!')
)
I feel like it would be a lot cleaner.
Hi, thanks for the feedback. The two reasons it's like that are:
- Splitting them reduces the clutter (number of parameters) in the
PreciseRunner
class - Sometimes the engine used is a
ListenerEngine
instead ofPreciseEngine
(like here).
However, we could still get around this having an optional listener=None
parameter. So, are you saying you think something like this would ultimately be better?:
class PreciseRunner:
def __init__(self, engine_exe, model_file, chunk_size=2048, listener=None, trigger_level=3, sensitivity=0.5, stream=None, on_prediction=lambda x: None, on_activation=lambda: None):
I feel like that would be better and cleaner than the current implementation
Would it be possible to also add another initialization parameter to automatically start listening when the class is instantiated? Something along the lines of:
class PreciseRunner:
def __init__(self,
engine_exe, model_file,
chunk_size=2048,
listener=None,
trigger_level=3,
sensitivity=0.5,
stream=None,
on_prediction=lambda x: None,
on_activation=lambda: None
auto_start = False # Adding this
):
engine_exe
should also become engine_executable
since some developers might become confused and think it is a windows specific parameter.
How about engine_bin
? And I suppose a start=True
would be reasonable
engine_bin
does sound a lot better! I was also wondering how long it would take to implement the changes?
Feel free to implement this as a pull request. Otherwise, I'll probably be able to get to it some time this week
I think I'll just go ahead and wait for someone else to do it. I'm not familiar with this repositories code base and I'd rather not break everything.