def uni_man_client_protocol_speech_transcribe(self,
                                               event=None,
                                               call_uuid=None,
                                               udp_port=None,
                                               speech_data=None):
     """
     It is send command unicast manager to ivr program.
     :param event: jsonnode message.
     :param call_uuid: call uuid.
     :param udp_port: udp port.
     :param speech_data: speech transcribed message.
     :return: defer callback.
     """
     log.debug(' Send Command "speech_transcribe" : %s' % event)
     msg = jsonnode.NodeMessage()
     msg["timestamp"] = time.time()
     msg["msg"] = "Reply >> speech transcribe"
     msg["Reply-Text"] = "+OK"
     msg["msg-uuid"] = utils.getUUID()
     msg['call_uuid'] = event['call_uuid']
     msg['udp_port'] = event['udp_port']
     msg['command'] = 'speech_transcribe'
     msg['speech_data'] = event['speech_data']
     # msg = {}
     df = self.sendCommand(msg)
     df.addCallback(self.command_success_respone)
     df.addErrback(self.command_error_response)
     self.transport.loseConnection()
     return df
 def send_udp_port(self, event):
     log.debug('Receive Command "check_port" : %s' % event)
     msg = jsonnode.NodeMessage()
     msg["timestamp"] = time.time()
     msg["msg"] = "Reply >> %s" % event["msg"]
     # msg["Reply-Text"] = "+OK"
     msg["msg-uuid"] = event["msg-uuid"]
     msg['call_uuid'] = event['call_uuid']
     self.call_uuid = event['call_uuid']
     msg['udp_port'] = event['udp_port']
     # self.sendCommandReply(msg)
     global MAX_SESSIONS
     if self.users >= MAX_SESSIONS:
     # if True:
         msg["Reply-Text"] = "- ERR"
         self.sendCommandReply(msg)
         # self.transport.loseConnection()
         log.error('Reactor will stop.')
         reactor.callLater(2, reactor.stop)
     else:
         msg["Reply-Text"] = "+OK"
         port = self.check_port_available()
         if port:
             msg['udp_port'] = port
         else:
             log.error('Port not found.')
             msg['udp_port'] = None
     if self.start_udp_receiver(udp_port=port):
         self.sendCommandReply(msg)
     else:
         log.error('udp port not able to start')
         msg["Reply-Text"] = "- ERR"
         self.sendCommandReply(msg)
     # self.start_udp_receiver(udp_port=port)
     self.transport.loseConnection()
 def free_port(self, event):
     log.debug(' Receive Command  "get_free_port" : %s' % event)
     msg = jsonnode.NodeMessage()
     msg["timestamp"] = time.time()
     msg["msg"] = "Reply >> %s" % event["msg"]
     msg["Reply-Text"] = "+OK"
     msg["msg-uuid"] = event["msg-uuid"]
     msg['call_uuid'] = event['call_uuid']
     msg['udp_port'] = self.udp_port
     self.call_uuid = event['call_uuid']
     self.msg = msg
     self.connect_client_unicast_man_to_uni_rea()
 def speech_transcribe(self, event):
     log.debug(' Received command "speech_transcribe" : %s' % event)
     msg = jsonnode.NodeMessage()
     msg["timestamp"] = time.time()
     msg["msg"] = "Reply >> %s" % event["msg"]
     msg["Reply-Text"] = "+OK"
     msg["msg-uuid"] = event["msg-uuid"]
     msg['call_uuid'] = event['call_uuid']
     msg['udp_port'] = event['udp_port']
     msg['speech_data'] = event['speech_data']
     self.sendCommandReply(msg)
     self.speech_transcribed(call_uuid=event['call_uuid'],
                             msg=event['speech_data'])
 def uni_man_speech_transcribe(self, event):
     log.debug(' Receive Command  "uni_man_speech_transcribe" : %s' % event)
     msg = jsonnode.NodeMessage()
     msg["timestamp"] = time.time()
     msg["msg"] = "Reply >> %s" % event["msg"]
     msg["Reply-Text"] = "+OK"
     msg["msg-uuid"] = event["msg-uuid"]
     msg['call_uuid'] = event['call_uuid']
     msg['udp_port'] = event['udp_port']
     msg['speech_data'] = event['speech_data']
     # msg['port'] = event['port']
     # self.sendCommandReply(msg)
     self.connect_client_unicast_man_to_ivr(msg=msg)
 def get_free_port(self, call_uuid=None, udp_port=None):
     # Something like this
     msg = jsonnode.NodeMessage()
     msg['msg'] = None
     msg["timestamp"] = time.time()
     msg["msg-uuid"] = utils.getUUID()
     msg['command'] = 'get_free_port'
     msg['call_uuid'] = call_uuid
     msg['udp_port'] = udp_port
     # msg = {}
     df = self.sendCommand(msg)
     df.addCallback(self.command_success_respone)
     df.addErrback(self.command_error_response)
     return df
示例#7
0
 def curtum_speech_transcribe(self,
                              call_uuid=None,
                              udp_port=None,
                              speech_data=None):
     log.debug(' Receive Command "uni_man_speech_transcribe"')
     msg = jsonnode.NodeMessage()
     msg['msg'] = None
     msg["timestamp"] = time.time()
     msg["msg-uuid"] = utils.getUUID()
     msg['command'] = 'uni_man_speech_transcribe'
     msg['call_uuid'] = call_uuid
     msg['speech_data'] = speech_data
     msg['udp_port'] = udp_port
     # msg = {}
     df = self.sendCommand(msg)
     df.addCallback(self.command_success_respone)
     df.addErrback(self.command_error_response)
     self.transport.loseConnection()
     return df
 def check_port(self, call_uuid=None, udp_port=None):
     """
     It send command check_port to unicast reader program from unicast manager.
     :param call_uuid: call uuid.
     :param udp_port: port number.
     :return: defer callback.
     """
     log.debug(' Send Command "check_port" for call uuid : %s' % call_uuid)
     msg = jsonnode.NodeMessage()
     msg['msg'] = None
     msg["timestamp"] = time.time()
     msg["msg-uuid"] = utils.getUUID()
     msg['command'] = 'check_port'
     msg['call_uuid'] = call_uuid
     msg['udp_port'] = udp_port
     # msg = {}
     df = self.sendCommand(msg)
     df.addCallback(self.command_success_respone)
     df.addErrback(self.command_error_response)
     return df