mycroft-precise icon indicating copy to clipboard operation
mycroft-precise copied to clipboard

Combining PreciseRunner and PreciseEngine

Open Technerder opened this issue 5 years ago • 8 comments

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.

Technerder avatar May 13 '19 15:05 Technerder

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 of PreciseEngine (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):

MatthewScholefield avatar May 13 '19 15:05 MatthewScholefield

I feel like that would be better and cleaner than the current implementation

Technerder avatar May 13 '19 15:05 Technerder

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
    ):

Technerder avatar May 13 '19 16:05 Technerder

engine_exe should also become engine_executable since some developers might become confused and think it is a windows specific parameter.

Technerder avatar May 14 '19 15:05 Technerder

How about engine_bin? And I suppose a start=True would be reasonable

MatthewScholefield avatar May 14 '19 17:05 MatthewScholefield

engine_bin does sound a lot better! I was also wondering how long it would take to implement the changes?

Technerder avatar May 14 '19 17:05 Technerder

Feel free to implement this as a pull request. Otherwise, I'll probably be able to get to it some time this week

MatthewScholefield avatar May 14 '19 17:05 MatthewScholefield

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.

Technerder avatar May 24 '19 03:05 Technerder