示例#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
示例#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)
示例#3
0
 def say_(self, cmd):
     """ Say command """
     result = eval(cmd, globals(), self.slots)
     MSG = "{}: {}".format(self.name, result)
     print(MSG)
     if self.client:
         data = {
             'msg': result,
             'spk': self.name,
             'webclient_sid': self.webclient_sid
         }
         self.client.emit('say', data, namespace="/cv")
     if self.tts:
         stop_listening()
         tts(result)
         start_listening()
     else:
         pass
示例#4
0
    def say_(self, cmd):
        """ Say command """

        result = eval(cmd, globals(), self.slots)
        if self.tts == 'google':
            stop_listening()
            tts_google(result)
            start_listening()
        elif self.tts == 'local':
            stop_listening()
            tts_local(result)
            start_listening()
        else:
            pass
        MSG = "{}: {}".format(self.name, result)
        if self.host:
            self.socket_state.emit('say', {"msg": MSG})
        else:
            print(MSG)