parameters: (self, detected_callback=play_audio_file,
                interrupt_check=lambda: False,
                sleep_time=0.03)
docstring: Start the voice detector. For every `sleep_time` second it checks the
          audio buffer for triggering keywords. If detected, then call
          corresponding function in `detected_callback`, which can be a single
          function (single model) or a list of callback functions (multiple
          models). Every loop it also calls `interrupt_check` -- if it returns
          True, then breaks from the loop and return.
  
          :param detected_callback: a function or list of functions. The number of
                                    items must match the number of models in
                                    `decoder_model`.
          :param interrupt_check: a function that returns True if the main loop
                                  needs to stop.
          :param float sleep_time: how much time in second every loop waits.
          :return: None
docstring_summary: Start the voice detector. For every `sleep_time` second it checks the
          audio buffer for triggering keywords. If detected, then call
          corresponding function in `detected_callback`, which can be a single
          function (single model) or a list of callback functions (multiple
          models). Every loop it also calls `interrupt_check` -- if it returns
          True, then breaks from the loop and return.
docstring_tokens: Start the voice detector . For every sleep_time second it checks the audio buffer for triggering keywords . If detected then call corresponding function in detected_callback which can be a single function ( single model ) or a list of callback functions ( multiple models ) . Every loop it also calls interrupt_check -- if it returns True then breaks from the loop and return .
function: def start(self, detected_callback=play_audio_file,
                interrupt_check=lambda: False,
                sleep_time=0.03):
          """
          Start the voice detector. For every `sleep_time` second it checks the
          audio buffer for triggering keywords. If detected, then call
          corresponding function in `detected_callback`, which can be a single
          function (single model) or a list of callback functions (multiple
          models). Every loop it also calls `interrupt_check` -- if it returns
          True, then breaks from the loop and return.
  
          :param detected_callback: a function or list of functions. The number of
                                    items must match the number of models in
                                    `decoder_model`.
          :param interrupt_check: a function that returns True if the main loop
                                  needs to stop.
          :param float sleep_time: how much time in second every loop waits.
          :return: None
          """
  
          self.init_recording()
  
          if interrupt_check():
              logger.debug("detect voice return")
              return
  
          tc = type(detected_callback)
          if tc is not list:
              detected_callback = [detected_callback]
          if len(detected_callback) == 1 and self.num_hotwords > 1:
              detected_callback *= self.num_hotwords
  
          assert self.num_hotwords == len(detected_callback), \
              "Error: hotwords in your models (%d) do not match the number of " \
              "callbacks (%d)" % (self.num_hotwords, len(detected_callback))
  
          logger.debug("detecting...")
  
          while True:
              if interrupt_check():
                  logger.debug("detect voice break")
                  break
              data = self.ring_buffer.get()
              if len(data) == 0:
                  time.sleep(sleep_time)
                  continue
  
              ans = self.detector.RunDetection(data)
              if ans == -1:
                  logger.warning("Error initializing streams or reading audio data")
              elif ans > 0:
                  message = "Keyword " + str(ans) + " detected at time: "
                  message += time.strftime("%Y-%m-%d %H:%M:%S",
                                           time.localtime(time.time()))
                  logger.info(message)
                  callback = detected_callback[ans-1]
                  if callback is not None:
                      callback()
  
          logger.debug("finished.")
function_tokens: def start ( self , detected_callback = play_audio_file , interrupt_check = lambda : False , sleep_time = 0.03 ) : self . init_recording ( ) if interrupt_check ( ) : logger . debug ( "detect voice return" ) return tc = type ( detected_callback ) if tc is not list : detected_callback = [ detected_callback ] if len ( detected_callback ) == 1 and self . num_hotwords > 1 : detected_callback *= self . num_hotwords assert self . num_hotwords == len ( detected_callback ) , "Error: hotwords in your models (%d) do not match the number of " "callbacks (%d)" % ( self . num_hotwords , len ( detected_callback ) ) logger . debug ( "detecting..." ) while True : if interrupt_check ( ) : logger . debug ( "detect voice break" ) break data = self . ring_buffer . get ( ) if len ( data ) == 0 : time . sleep ( sleep_time ) continue ans = self . detector . RunDetection ( data ) if ans == - 1 : logger . warning ( "Error initializing streams or reading audio data" ) elif ans > 0 : message = "Keyword " + str ( ans ) + " detected at time: " message += time . strftime ( "%Y-%m-%d %H:%M:%S" , time . localtime ( time . time ( ) ) ) logger . info ( message ) callback = detected_callback [ ans - 1 ] if callback is not None : callback ( ) logger . debug ( "finished." )