def on_result(self, text): if not text.strip() or len(text.split()) > 1: #print 'empty text' return cmd = text.lower() if cmd in ('sleep', 'quiet',): #print 'going to sleep' self.is_interpreting = False elif cmd == 'wake': #print 'waking up' self.is_interpreting = True elif self.is_interpreting: interpret_command(cmd)
def on_result(self, text): if not text.strip() or len(text.split()) > 1: #print 'empty text' return cmd = text.lower() if cmd in ( 'sleep', 'quiet', ): #print 'going to sleep' self.is_interpreting = False elif cmd == 'wake': #print 'waking up' self.is_interpreting = True elif self.is_interpreting: interpret_command(cmd)
set_current_controller(ObjectController) if '-i' in sys.argv or '--interactive' in sys.argv: t = threading.Thread(target=run_server) t.daemon = True try: t.start() try: exit_cmd = 'exit' print 'Kill server and exit with "%s"' % exit_cmd while True: cmd = raw_input('(speak) ').strip().lower() if not cmd: pass elif cmd == exit_cmd: break if not interpret_command(cmd): print 'bad unrecognized command "%s"' % cmd except EOFError: print 'EOF' except KeyboardInterrupt: pass except Exception as e: logging.exception(e) finally: cleanup_server() else: run_server() cleanup_server()