Exemple #1
0
    def input_(self, line):
        """ Input command """
        m = re_input.match(line)

        if m:
            print("USER: "******"{} [{}]".format(result, filename))
            else:
                result = input()

            idd = m.group('id')
            raw = result
            if m.group('filter'):
                fil = m.group('filter')
                args = m.group('args').split()
                slots_ = dict(self.slots)
                slots_['args'] = args
                result = eval('{}("{}",*args)'.format(fil, result), globals(),
                              slots_)
            if self.host:
                self.socket_state.emit(
                    'input', {"msg": "USER: {}/{}".format(result, raw)})
            self.slots[idd] = result
Exemple #2
0
    def input_(self, line):
        """ Input command """
        self.input = None
        m = re_input.match(line)

        if m:
            print("USER: "******"/cv")
                while not self.input:
                    time.sleep(0.1)
                result = self.input

            elif self.speech_recognition:
                start_listening()
                filename = None
                while not filename:
                    time.sleep(0.1)
                    filename = pull_latest()

                result = sr_google(filename)
                if self.client:
                    data = {
                        'spk': self.name,
                        "msg": result,
                        'webclient_sid': self.webclient_sid
                    }
                    self.client.emit('input log', data, namespace="/cv")
            else:
                result = input()

            idd = m.group('id')
            raw = result
            if m.group('filter'):
                fil = m.group('filter')
                args = m.group('args').split()
                slots_ = dict(self.slots)
                slots_['args'] = args
                slots_['self'] = self
                result = eval('{}(self,"{}",*args)'.format(fil, result),
                              globals(), slots_)
            if not idd == '_':
                self.slots[idd] = result
            else:
                print('RES', result)
                if isinstance(result, dict):
                    self.slots.update(result)