Kitt-AI / snowboy

Future versions with model training module will be maintained through a forked version here: https://github.com/seasalt-ai/snowboy
Other
3.08k stars 997 forks source link

Question about multimodel detect #310

Closed boshkash1151 closed 6 years ago

boshkash1151 commented 6 years ago

I am trying to add multiple models using the following code

 class bla:

        def populate_actions(self,actions):
              self.actions = actions
              for i in range(0,len(self.actions)):
              self.models.append(self.actions[i].get_model())
              self.commands_callbacks.append(lambda: self.actions[i].action_hotword_detected_callback())**

and then starting the models using the following:

   def start_hotword_detected_callback(self):

          sensitivity=[0.5]*len(self.models)
          self.commands_detector = snowboydecoder.HotwordDetector(self.models, sensitivity=sensitivity)
          self.commands_detector.start(detected_callback=self.commands_callbacks,sleep_time=0.03)

the problem is that all hotwords only call the first hotword callback while if Iused the following to specify the models and call backs it works

   class bla:

          def populate_actions(self,actions):
                 self.actions = actions
                 for i in range(0,len(self.actions)):
                        self.models.append(self.actions[i].get_model())
                        self.commands_callbacks=[]
                 self.commands_callbacks.append(lambda:self.actions[0].action_hotword_detected_callback())
                 self.commands_callbacks.append(lambda:self.actions[1].action_hotword_detected_callback())

what i am doing wrong

chenguoguo commented 6 years ago

Were you following this demo?

From your code I couldn't tell if your callback functions are the same or not.

boshkash1151 commented 6 years ago

Yes I followed the demo and it works and also the other type of calling the method works.

All what I have different than the demo is that the callbacks are object methods

chenguoguo commented 6 years ago

This is really a Python programing issue. Perhaps you could look more into Python grammars?

boshkash1151 commented 6 years ago

@chenguoguo ,

OK i will try to search online thanks